author | Claus Gittinger <cg@exept.de> |
Thu, 29 Jan 2015 18:54:22 +0100 | |
changeset 3472 | a61d50c15405 |
parent 3325 | 802a684bf3d9 |
child 3598 | 04be25181a2e |
permissions | -rw-r--r-- |
304 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
891 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
3472 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
3174 | 16 |
CharacterArray subclass:#Text |
963
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
17 |
instanceVariableNames:'string runs' |
2322 | 18 |
classVariableNames:'BackgroundColorEmphasis ColorEmphasis ItalicEmphasis BoldEmphasis |
19 |
UnderlineEmphasis UnderwaveEmphasis OverlineEmphasis |
|
20 |
StrikeoutEmphasis ReverseEmphasis BoldUnderlineEmphasis |
|
21 |
BoldOverlineEmphasis BoldUnderwaveEmphasis |
|
22 |
ItalicUnderlineEmphasis ItalicUnderwaveEmphasis |
|
3158 | 23 |
UnderlineColorEmphasis StrikeoutColorEmphasis EtchColorEmphasis |
24 |
FontEmphasis' |
|
963
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
25 |
poolDictionaries:'' |
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
26 |
category:'Collections-Text' |
304 | 27 |
! |
28 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
29 |
!Text class methodsFor:'documentation'! |
304 | 30 |
|
31 |
copyright |
|
32 |
" |
|
33 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
34 |
All Rights Reserved |
|
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
||
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
Texts add emphasis information to a string. |
|
343 | 49 |
Texts and strings should behave interchanchably to the outside |
50 |
world, except that texts keep per-character emphasis information. |
|
51 |
(strings return nil, when asked for an elements emphasis). |
|
52 |
Use #string, to get a texts underlying string without any emphasis |
|
53 |
information. |
|
304 | 54 |
|
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
55 |
Currently, the following attributes are supported: |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
56 |
#bold |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
57 |
#italic |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
58 |
#underline |
759
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
59 |
#underwave |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
60 |
#strikeout |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
61 |
(#color -> aColor) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
62 |
(#backgroundColor -> aColor) |
759
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
63 |
(#underlineColor -> aColor) |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
64 |
(#strikeoutColor -> aColor) |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
65 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
66 |
Attributes may be combined (pass an array of above) as emphasis. |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
67 |
See examples. |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
68 |
|
304 | 69 |
This class is not yet fully implemented - being constructed. |
70 |
||
71 |
[author:] |
|
72 |
Claus Gittinger |
|
73 |
||
74 |
[see also:] |
|
75 |
CharacterArray String RunArray |
|
76 |
" |
|
313 | 77 |
! |
78 |
||
79 |
examples |
|
80 |
" |
|
343 | 81 |
plain string (for comparison): |
313 | 82 |
[exBegin] |
83 |
Dialog |
|
84 |
warn:'hello' |
|
85 |
[exEnd] |
|
343 | 86 |
|
87 |
||
88 |
emphasized strings as dialog titles: |
|
313 | 89 |
[exBegin] |
90 |
Dialog |
|
91 |
warn:((Text string:'hello') allBold) |
|
92 |
[exEnd] |
|
93 |
[exBegin] |
|
94 |
Dialog |
|
95 |
warn:(Text string:'hello' emphasis:#italic) |
|
96 |
[exEnd] |
|
97 |
[exBegin] |
|
98 |
Dialog |
|
702
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
99 |
warn:(Text string:'hello' emphasis:#(underline)) |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
100 |
[exEnd] |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
101 |
[exBegin] |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
102 |
Dialog |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
103 |
warn:(Text string:'hello' emphasis:#(underwave)) |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
104 |
[exEnd] |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
105 |
[exBegin] |
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
106 |
Dialog |
313 | 107 |
warn:(Text string:'hello' emphasis:#(bold underline)) |
108 |
[exEnd] |
|
109 |
[exBegin] |
|
110 |
Dialog |
|
111 |
warn:(Text string:'hello' |
|
112 |
emphasis:(Array with:#bold |
|
113 |
with:#strikeout |
|
114 |
with:(#color->Color red))) |
|
115 |
[exEnd] |
|
116 |
[exBegin] |
|
117 |
Dialog |
|
315 | 118 |
warn:(Text string:'hello' |
759
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
119 |
emphasis:(Array with:(#color->Color black) |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
120 |
with:#underwave |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
121 |
with:(#underlineColor->Color red))) |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
122 |
[exEnd] |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
123 |
[exBegin] |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
124 |
Dialog |
3527d6b2fb6d
new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
125 |
warn:(Text string:'hello' |
315 | 126 |
emphasis:(Array with:#bold |
127 |
with:#strikeout |
|
128 |
with:(#color->Color red) |
|
129 |
with:(#backgroundColor->Color yellow))) |
|
130 |
[exEnd] |
|
131 |
[exBegin] |
|
132 |
Dialog |
|
313 | 133 |
warn:(Text string:'hello' color:(Color red)) |
134 |
[exEnd] |
|
135 |
||
343 | 136 |
|
137 |
in an editTextView: |
|
138 |
[exBegin] |
|
139 |
|t v| |
|
140 |
||
141 |
t := 'The quick brown fox jumps over the lazy dog' asText. |
|
142 |
t emphasizeFrom:(t findString:'quick') count:5 with:#bold. |
|
143 |
t emphasizeFrom:(t findString:'brown') count:9 |
|
144 |
with:(Array with:#color->(Color name:'brown') |
|
145 |
with:#bold). |
|
146 |
t emphasizeFrom:(t findString:'lazy') count:4 |
|
147 |
with:(Array with:#color->(Color red) |
|
148 |
with:#italic). |
|
149 |
t emphasizeFrom:(t findString:'dog') count:3 with:#underline. |
|
150 |
||
151 |
v := HVScrollableView for:EditTextView. |
|
152 |
v contents:t. |
|
153 |
||
154 |
v width:450. |
|
155 |
v open. |
|
156 |
[exEnd] |
|
313 | 157 |
" |
304 | 158 |
! ! |
159 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
160 |
!Text class methodsFor:'initialization'! |
314 | 161 |
|
162 |
initialize |
|
163 |
"initialize the class" |
|
164 |
||
165 |
" |
|
166 |
consider this a kludge: |
|
167 |
I want to inherit behavior from CharacterArray, but not |
|
168 |
its implementation (indexed access). |
|
169 |
" |
|
170 |
||
2322 | 171 |
self flags:(Behavior flagRegular). |
172 |
||
173 |
BackgroundColorEmphasis := #backgroundColor. |
|
174 |
ColorEmphasis := #color. |
|
175 |
ItalicEmphasis := #italic. |
|
176 |
BoldEmphasis := #bold. |
|
177 |
UnderlineEmphasis := #underline. |
|
178 |
UnderwaveEmphasis := #underwave. |
|
179 |
OverlineEmphasis := #overline. |
|
180 |
StrikeoutEmphasis := #strikeout. |
|
181 |
ReverseEmphasis := #reverse. |
|
182 |
BoldUnderlineEmphasis := #boldUnderline. |
|
183 |
BoldOverlineEmphasis := #boldOverline. |
|
184 |
BoldUnderwaveEmphasis := #boldUnderwave. |
|
185 |
ItalicUnderlineEmphasis := #italicUnderline. |
|
186 |
ItalicUnderwaveEmphasis := #italicUnderwave. |
|
187 |
UnderlineColorEmphasis := #underlineColor. |
|
188 |
StrikeoutColorEmphasis := #strikeoutColor. |
|
189 |
EtchColorEmphasis := #etchColor. |
|
3158 | 190 |
FontEmphasis := #font. |
314 | 191 |
|
192 |
" |
|
193 |
Text initialize |
|
194 |
" |
|
195 |
||
196 |
"Modified: 12.5.1996 / 17:53:50 / cg" |
|
197 |
! ! |
|
198 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
199 |
!Text class methodsFor:'instance creation'! |
304 | 200 |
|
201 |
fromString:aString |
|
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
202 |
"create a Text instance, for the characters in aString, |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
203 |
without emphasis." |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
204 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
205 |
^ super new string:aString emphasis:nil |
304 | 206 |
|
207 |
" |
|
208 |
Text fromString:'hello' |
|
209 |
" |
|
210 |
||
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
211 |
"Modified: 12.5.1996 / 17:05:34 / cg" |
304 | 212 |
! |
213 |
||
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
214 |
new |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
215 |
"create a new empty Text instance. |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
216 |
Redefined for string-protocol compatibility" |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
217 |
|
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
218 |
^ super new string:(String new) emphasis:nil |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
219 |
|
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
220 |
"Text new" |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
221 |
|
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
222 |
"Modified: 12.5.1996 / 17:05:17 / cg" |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
223 |
"Modified: 31.12.1996 / 12:39:57 / stefan" |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
224 |
! |
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
225 |
|
307 | 226 |
new:size |
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
227 |
"create a new empty Text instance. |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
228 |
Redefined for string-protocol compatibility" |
307 | 229 |
|
230 |
^ self string:(String new:size) |
|
231 |
||
232 |
"Created: 12.5.1996 / 11:57:27 / cg" |
|
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
233 |
"Modified: 12.5.1996 / 17:05:17 / cg" |
307 | 234 |
! |
235 |
||
304 | 236 |
string:aString |
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
237 |
"create a Text instance, for the characters in aString, |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
238 |
without emphasis." |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
239 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
240 |
^ super new string:aString emphasis:nil |
304 | 241 |
|
242 |
" |
|
243 |
Text string:'hello' |
|
244 |
" |
|
245 |
||
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
246 |
"Modified: 12.5.1996 / 17:05:00 / cg" |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
247 |
! |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
248 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
249 |
string:aString color:aColor |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
250 |
"create a Text instance, for the characters in aString, |
345
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
251 |
which are colored as aColor (only the foregroundColor is affected). |
496 | 252 |
This is a shortCut for creating an emphasis of (#color->aColor)" |
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
253 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
254 |
^ super new string:aString emphasis:(#color->aColor) |
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
255 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
256 |
" |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
257 |
Dialog |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
258 |
information:(Text string:'hello' color:(Color red)) |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
259 |
" |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
260 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
261 |
"Created: 12.5.1996 / 17:03:20 / cg" |
496 | 262 |
"Modified: 27.2.1997 / 10:13:36 / cg" |
344
72fe9b7ae4b5
added #string:color:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
263 |
! |
72fe9b7ae4b5
added #string:color:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
264 |
|
304 | 265 |
string:aString emphasis:attribute |
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
266 |
"create a Text instance, for the characters in aString, |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
267 |
which are emphasized as described by attribute." |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
268 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
269 |
^ super new string:aString emphasis:attribute |
304 | 270 |
|
271 |
" |
|
272 |
Text string:'hello' emphasis:#bold |
|
309
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
273 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
274 |
Dialog |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
275 |
information:(Text string:'hello' emphasis:#bold) |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
276 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
277 |
Dialog |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
278 |
information:(Text string:'hello' emphasis:#italic) |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
279 |
|
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
280 |
Dialog |
6458ec5cc033
added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents:
308
diff
changeset
|
281 |
information:(Text string:'hello' emphasis:#underline) |
310 | 282 |
|
283 |
Dialog |
|
284 |
information:(Text string:'hello' emphasis:#strikeout) |
|
304 | 285 |
" |
286 |
||
310 | 287 |
"Modified: 12.5.1996 / 17:16:03 / cg" |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
288 |
! |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
289 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
290 |
string:aString emphasisCollection:attributeCollection |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
291 |
"create a Text instance, for the characters in aString, |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
292 |
which are individually emphasized as described by attributeCollection." |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
293 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
294 |
^ super new string:aString emphasisCollection:attributeCollection |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
295 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
296 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
297 |
Text |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
298 |
string:'hello' |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
299 |
emphasisCollection:#(#bold #bold #italic #italic #italic) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
300 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
301 |
Dialog |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
302 |
information:(Text |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
303 |
string:'hello' |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
304 |
emphasisCollection:#(#bold #bold #italic #italic #(#underline italic))) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
305 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
306 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
307 |
"Created: 14.5.1996 / 14:02:18 / cg" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
308 |
"Modified: 14.5.1996 / 15:01:28 / cg" |
345
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
309 |
! |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
310 |
|
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
311 |
string:aString foregroundColor:fgColor backgroundColor:bgColor |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
312 |
"create a Text instance, for the characters in aString, |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
313 |
which are colored in fgColor on bgColor. |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
314 |
This is a shortCut for creating an emphasis of |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
315 |
#( #color->fgColor) (#backgroundColor->bgColor)" |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
316 |
|
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
317 |
^ super new |
345
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
318 |
string:aString |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
319 |
emphasis:(Array with:#color->fgColor |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
320 |
with:#backgroundColor->bgColor) |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
321 |
|
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
322 |
" |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
323 |
Dialog |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
324 |
information:(Text string:'hello' |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
325 |
foregroundColor:(Color red) |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
326 |
backgroundColor:(Color yellow)) |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
327 |
" |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
328 |
|
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
329 |
"Modified: 11.5.1996 / 14:21:01 / cg" |
062032f9e401
renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents:
344
diff
changeset
|
330 |
"Created: 16.5.1996 / 12:37:24 / cg" |
395 | 331 |
! |
332 |
||
333 |
string:aString runs:aRun |
|
334 |
"create a Text instance, for the characters in aString, |
|
335 |
which are individually emphasized as described by attributeCollection." |
|
336 |
||
466
a806fe2ac753
'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents:
454
diff
changeset
|
337 |
^ super new string:aString emphasisCollection:aRun. |
2016
9ad5248e5920
Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents:
1780
diff
changeset
|
338 |
! |
9ad5248e5920
Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents:
1780
diff
changeset
|
339 |
|
2259
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
340 |
uninitializedNew:size |
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
341 |
"for compatibility only" |
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
342 |
|
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
343 |
^ self new:size |
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
344 |
! |
d9b94e7b06a5
+uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
345 |
|
2867 | 346 |
writeStreamClass |
347 |
"the class used by writeStream" |
|
2016
9ad5248e5920
Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents:
1780
diff
changeset
|
348 |
|
2867 | 349 |
^ TextStream |
304 | 350 |
! ! |
351 |
||
2322 | 352 |
!Text class methodsFor:'emphasis constants'! |
353 |
||
354 |
backgroundColorEmphasis |
|
355 |
^ BackgroundColorEmphasis |
|
356 |
! |
|
357 |
||
358 |
foregroundColorEmphasis |
|
359 |
^ ColorEmphasis |
|
360 |
! ! |
|
361 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
362 |
!Text class methodsFor:'emphasis helper'! |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
363 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
364 |
addEmphasis:e1 to:e2 |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
365 |
"merge two emphasis's into one" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
366 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
367 |
|ne| |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
368 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
369 |
e1 isNil ifTrue:[^ e2]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
370 |
e2 isNil ifTrue:[^ e1]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
371 |
e1 == e2 ifTrue:[^ e1]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
372 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
373 |
(e1 isSymbol |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
374 |
or:[e1 isAssociation]) ifTrue:[ |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
375 |
(e2 isSymbol |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
376 |
or:[e2 isAssociation]) ifTrue:[ |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
377 |
^ Array with:e1 with:e2 |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
378 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
379 |
(e2 includes:e1) ifTrue:[^ e2]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
380 |
^ e2 copyWith:e1 |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
381 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
382 |
(e2 isSymbol |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
383 |
or:[e2 isAssociation]) ifTrue:[ |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
384 |
(e1 includes:e2) ifTrue:[^ e1]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
385 |
^ e1 copyWith:e2 |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
386 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
387 |
"/ ould use: |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
388 |
"/ ^ (e1 asSet addAll:e2; asArray) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
389 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
390 |
"/ but we do it manually, to preserve the |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
391 |
"/ order. (should create longer runs, while editing) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
392 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
393 |
ne := e1. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
394 |
e2 do:[:e | |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
395 |
(ne includes:e) ifFalse:[ |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
396 |
ne := ne copyWith:e |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
397 |
] |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
398 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
399 |
^ ne. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
400 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
401 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
402 |
Text addEmphasis:#bold to:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
403 |
Text addEmphasis:#bold to:#italic |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
404 |
Text addEmphasis:#bold to:#(italic strikeout) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
405 |
Text addEmphasis:#italic to:#(italic strikeout) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
406 |
Text addEmphasis:#(italic strikeout) to:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
407 |
Text addEmphasis:#(italic strikeout) to:#italic |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
408 |
Text addEmphasis:#(italic strikeout) to:#(bold underline) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
409 |
Text addEmphasis:(#color->Color red) to:#(bold underline) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
410 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
411 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
412 |
"Modified: 14.5.1996 / 17:15:44 / cg" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
413 |
! |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
414 |
|
339 | 415 |
emphasis:e1 includes:e2 |
416 |
"return true, if e1 includes e2. |
|
417 |
e2 should be a single emphasis." |
|
418 |
||
419 |
e1 isNil ifTrue:[^ false]. |
|
420 |
e2 isNil ifTrue:[^ false]. |
|
421 |
e1 == e2 ifTrue:[^ true]. |
|
422 |
||
754 | 423 |
e1 isSymbol ifTrue:[ |
424 |
^ false |
|
425 |
]. |
|
426 |
e1 isAssociation ifTrue:[ |
|
427 |
^ e1 key == e2 |
|
428 |
]. |
|
339 | 429 |
(e1 isSymbol |
430 |
or:[e1 isAssociation]) ifTrue:[ |
|
431 |
^ false |
|
432 |
]. |
|
1780 | 433 |
e2 isSymbol ifTrue:[ |
434 |
^ (e1 includes:e2) or:[e1 contains:[:e |e isAssociation and:[e key == e2]]]. |
|
435 |
]. |
|
436 |
e2 isAssociation ifTrue:[ |
|
437 |
^ (e1 includes:e2 key) or:[e1 contains:[:e |e isAssociation and:[e key == e2 key]]]. |
|
339 | 438 |
]. |
439 |
^ false |
|
440 |
||
441 |
" |
|
442 |
Text emphasis:#bold includes:#bold |
|
1780 | 443 |
Text emphasis:#bold includes:#italic |
339 | 444 |
Text emphasis:#(italic strikeout) includes:#bold |
445 |
Text emphasis:#(italic strikeout) includes:#italic |
|
754 | 446 |
Text emphasis:(#color->Color red) includes:#color |
339 | 447 |
" |
448 |
||
449 |
"Modified: 14.5.1996 / 17:45:11 / cg" |
|
450 |
! |
|
451 |
||
407 | 452 |
extractEmphasis:key from:e |
453 |
"if key is included in the emphasis, e then return the key. |
|
454 |
Otherwise, if a n association with that key is included, return the value. |
|
455 |
Otherwise, return nil." |
|
456 |
||
457 |
e isNil ifTrue:[^ nil]. |
|
458 |
key == e ifTrue:[^ e]. |
|
754 | 459 |
e isSymbol ifTrue:[^ nil]. |
407 | 460 |
|
461 |
e isAssociation ifTrue:[ |
|
462 |
e key == key ifTrue:[^ e value]. |
|
463 |
^ nil |
|
464 |
]. |
|
465 |
e do:[:entry | |
|
754 | 466 |
entry == key ifTrue:[^ key]. |
407 | 467 |
entry isAssociation ifTrue:[ |
468 |
entry key == key ifTrue:[ |
|
469 |
^ entry value |
|
470 |
] |
|
471 |
] |
|
472 |
]. |
|
473 |
^ nil |
|
474 |
||
475 |
" |
|
476 |
Text extractEmphasis:#bold from:#bold |
|
477 |
Text extractEmphasis:#bold from:#italic |
|
478 |
Text extractEmphasis:#bold from:#(italic strikeout) |
|
479 |
Text extractEmphasis:#bold from:#(italic bold) |
|
480 |
Text extractEmphasis:#color from:(#color->Color red) |
|
481 |
Text extractEmphasis:#color from:(#foo->Color red) |
|
482 |
" |
|
483 |
||
484 |
"Modified: 14.5.1996 / 17:45:11 / cg" |
|
485 |
"Created: 11.7.1996 / 09:49:58 / cg" |
|
486 |
! |
|
487 |
||
2731
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
488 |
removeEmphasis:emToRemove from:empArg |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
489 |
"remove an emphasis; if it was not in empArg, do nothing" |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
490 |
|
2731
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
491 |
|ne idx emp| |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
492 |
|
2731
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
493 |
emp := empArg. |
1068 | 494 |
emToRemove isNil ifTrue:[^ emp]. |
495 |
emp isNil ifTrue:[^ emp]. |
|
496 |
emToRemove == emp ifTrue:[^ nil]. |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
497 |
|
1068 | 498 |
emp isSymbol ifTrue:[ |
499 |
emToRemove isSymbol ifTrue:[^ emp]. "/ knowing they are not identical |
|
500 |
emToRemove isAssociation ifTrue:[ |
|
501 |
emToRemove key == emp ifTrue:[^ nil]. |
|
502 |
^ emp |
|
755 | 503 |
]. |
1068 | 504 |
(emToRemove includes:emp) ifTrue:[^ nil]. |
505 |
^ emp |
|
755 | 506 |
]. |
1068 | 507 |
emp isAssociation ifTrue:[ |
508 |
emToRemove isSymbol ifTrue:[ |
|
509 |
emp key == emToRemove ifTrue:[^ nil]. |
|
510 |
^ emp |
|
755 | 511 |
]. |
1068 | 512 |
emToRemove isAssociation ifTrue:[ |
513 |
emToRemove key == emp key ifTrue:[^ nil]. |
|
514 |
^ emp |
|
755 | 515 |
]. |
1068 | 516 |
(emToRemove includes:emp) ifTrue:[^ nil]. |
517 |
^ emp |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
518 |
]. |
834
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
519 |
"/ e2 must be a collection |
1068 | 520 |
(emToRemove isSymbol |
521 |
or:[emToRemove isAssociation]) ifTrue:[ |
|
522 |
(emp includes:emToRemove) ifTrue:[ |
|
523 |
ne := emp copyWithout:emToRemove. |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
524 |
ne size == 1 ifTrue:[^ ne at:1]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
525 |
ne size == 0 ifTrue:[^ nil]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
526 |
^ ne |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
527 |
]. |
834
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
528 |
|
1068 | 529 |
idx := emp findFirst:[:em | em isAssociation and:[em key == emToRemove]]. |
2731
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
530 |
(idx ~~ 0) ifTrue:[ |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
531 |
emp := emp copyWithoutIndex:idx. |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
532 |
[ |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
533 |
idx := emp findFirst:[:em | em isAssociation and:[em key == emToRemove]] startingAt:idx. |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
534 |
idx ~~ 0 |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
535 |
] whileTrue:[ |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
536 |
emp := emp copyWithoutIndex:idx. |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
537 |
] |
834
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
538 |
]. |
1068 | 539 |
^ emp |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
540 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
541 |
|
754 | 542 |
"/ could use: |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
543 |
"/ ^ (e2 asSet removeAll:e1; asArray) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
544 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
545 |
"/ but we do it manually, to preserve the |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
546 |
"/ order. (should create longer runs, while editing) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
547 |
|
1068 | 548 |
ne := emp. |
549 |
emToRemove do:[:e | |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
550 |
(ne includes:e) ifTrue:[ |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
551 |
ne := ne copyWithout:e |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
552 |
] |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
553 |
]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
554 |
ne size == 1 ifTrue:[^ ne at:1]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
555 |
ne size == 0 ifTrue:[^ nil]. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
556 |
^ ne. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
557 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
558 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
559 |
Text removeEmphasis:#bold from:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
560 |
Text removeEmphasis:#bold from:#italic |
1067 | 561 |
Text removeEmphasis:#bold from:#(italic strikeout) |
3472 | 562 |
Text removeEmphasis:#bold from:#(italic bold strikeout) |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
563 |
Text removeEmphasis:#italic from:#(italic strikeout) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
564 |
Text removeEmphasis:#(italic strikeout) from:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
565 |
Text removeEmphasis:#(italic strikeout) from:#italic |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
566 |
Text removeEmphasis:#(italic strikeout) from:#(bold underline) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
567 |
Text removeEmphasis:#(italic strikeout bold) from:#(bold underline) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
568 |
Text removeEmphasis:#(italic strikeout bold underline) from:#(bold underline) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
569 |
Text removeEmphasis:(#color->Color red) from:#(bold underline) |
756 | 570 |
Text removeEmphasis:(#color->Color red) from:(#color->Color red) |
1067 | 571 |
Text removeEmphasis:#color from:(#color->Color red) |
572 |
Text removeEmphasis:#color from:(#backgroundColor->Color red) |
|
754 | 573 |
Text removeEmphasis:#color from:(Array with:#bold with:#underline with:#color->Color red) |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
574 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
575 |
|
2731
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
576 |
"Modified: / 25-01-2001 / 15:24:46 / ps" |
6dec3016c2a5
changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents:
2675
diff
changeset
|
577 |
"Modified (comment): / 06-03-2012 / 18:23:32 / cg" |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
578 |
! ! |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
579 |
|
735 | 580 |
!Text methodsFor:'accessing'! |
581 |
||
582 |
at:characterIndex |
|
583 |
"return the plain character at characterIndex" |
|
584 |
||
585 |
^ string at:characterIndex |
|
586 |
||
587 |
"Created: 11.5.1996 / 14:25:41 / cg" |
|
588 |
"Modified: 16.5.1996 / 11:15:33 / cg" |
|
589 |
! |
|
590 |
||
591 |
at:characterIndex put:aCharacter |
|
592 |
"change the character at characterIndex to be aCharacter. |
|
593 |
The emphasis (if any) of that character remains unchanged." |
|
594 |
||
595 |
^ string at:characterIndex put:aCharacter |
|
596 |
||
597 |
"Created: 11.5.1996 / 14:25:49 / cg" |
|
598 |
"Modified: 16.5.1996 / 11:15:57 / cg" |
|
2734 | 599 |
! |
600 |
||
601 |
byteAt:characterIndex |
|
602 |
"return the plain character at characterIndex" |
|
603 |
||
604 |
^ string byteAt:characterIndex |
|
605 |
||
606 |
"Created: 11.5.1996 / 14:25:41 / cg" |
|
607 |
"Modified: 16.5.1996 / 11:15:33 / cg" |
|
608 |
! |
|
609 |
||
610 |
byteAt:characterIndex put:aCharacter |
|
611 |
"change the character at characterIndex to be aCharacter. |
|
612 |
The emphasis (if any) of that character remains unchanged." |
|
613 |
||
614 |
^ string byteAt:characterIndex put:aCharacter |
|
615 |
||
616 |
"Created: 11.5.1996 / 14:25:49 / cg" |
|
617 |
"Modified: 16.5.1996 / 11:15:57 / cg" |
|
735 | 618 |
! ! |
619 |
||
304 | 620 |
!Text methodsFor:'comparing'! |
621 |
||
622 |
= aStringOrText |
|
623 |
"compare the receiver and the argument, ignoring emphasis" |
|
624 |
||
384 | 625 |
aStringOrText isString ifFalse:[^ false]. |
304 | 626 |
^ string = aStringOrText string |
627 |
||
628 |
||
629 |
" |
|
630 |
'hello' asText = 'hello' |
|
631 |
'hello' asText = 'hello' asText |
|
632 |
'hello' asText allBold = 'hello' |
|
633 |
" |
|
634 |
||
384 | 635 |
"Modified: 4.6.1996 / 11:14:58 / cg" |
662 | 636 |
! |
637 |
||
638 |
hash |
|
639 |
"return a suitable hashcode (req'd since = is redefined)" |
|
640 |
||
641 |
^ string hash |
|
642 |
||
643 |
"Created: / 19.6.1998 / 04:15:57 / cg" |
|
304 | 644 |
! ! |
645 |
||
646 |
!Text methodsFor:'converting'! |
|
647 |
||
648 |
asText |
|
1645 | 649 |
"return a Text-object (string with emphasis) from myself. |
650 |
I am already a text object." |
|
343 | 651 |
|
304 | 652 |
^ self |
653 |
||
654 |
"Created: 11.5.1996 / 14:08:36 / cg" |
|
343 | 655 |
"Modified: 16.5.1996 / 11:15:12 / cg" |
304 | 656 |
! ! |
657 |
||
658 |
!Text methodsFor:'copying'! |
|
659 |
||
660 |
, aStringOrText |
|
2733 | 661 |
"concatenate the receiver's characters with the argument's characters, |
343 | 662 |
and return string or text object containing those characters. |
663 |
If either the receiver or the argument contains emphasis information, |
|
2733 | 664 |
a text object will be returned. |
665 |
Otherwise, a string (i.e. without emphasis) is returned." |
|
304 | 666 |
|
626 | 667 |
|newRuns| |
668 |
||
758 | 669 |
aStringOrText isCharacter ifTrue:[ |
670 |
^ self , aStringOrText asString |
|
671 |
]. |
|
615 | 672 |
aStringOrText hasChangeOfEmphasis ifTrue:[ |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
673 |
^ self species new |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
674 |
string:(string , aStringOrText) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
675 |
emphasisCollection:(runs , aStringOrText emphasisCollection) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
676 |
]. |
615 | 677 |
runs notNil "self hasChangeOfEmphasis" ifTrue:[ |
626 | 678 |
newRuns := runs copyFrom:1 to:(runs size). |
2852 | 679 |
newRuns add:nil withOccurrences:(aStringOrText size). |
408 | 680 |
^ self species new |
681 |
string:(string , aStringOrText) |
|
2852 | 682 |
emphasisCollection:newRuns |
408 | 683 |
]. |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
684 |
^ string , aStringOrText string |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
685 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
686 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
687 |
('hello' asText allBold) , ' world' |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
688 |
'hello' , (' world' asText allBold) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
689 |
'hello' , ' world' |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
690 |
('hello' asText allBold) , (' world' asText allBold) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
691 |
" |
304 | 692 |
|
2733 | 693 |
"Modified: / 31-03-1998 / 16:34:04 / cg" |
694 |
"Modified (comment): / 01-04-2012 / 13:20:02 / cg" |
|
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
695 |
! |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
696 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
697 |
concatenateFromString:aString |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
698 |
"return the concatenation of aString and myself. |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
699 |
This may be a Text (if I have emphasis) or a string (if not)." |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
700 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
701 |
self hasChangeOfEmphasis ifTrue:[ |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
702 |
^ self species new |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
703 |
string:(aString , string) |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
704 |
emphasisCollection:((RunArray new:(aString size)) , runs). |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
705 |
]. |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
706 |
^ aString , string |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
707 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
708 |
"Modified: 14.5.1996 / 15:56:05 / cg" |
394 | 709 |
! |
710 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
711 |
copyFrom:start to:stop |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
712 |
"return the subcollection starting at index start, anInteger and ending |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
713 |
at stop, anInteger." |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
714 |
|
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
715 |
self hasChangeOfEmphasis ifTrue:[ |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
716 |
^ self species new |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
717 |
string:(string copyFrom:start to:stop) |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
718 |
emphasisCollection:(runs copyFrom:start to:stop). |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
719 |
]. |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
720 |
^ string copyFrom:start to:stop |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
721 |
|
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
722 |
"Modified: 14.5.1996 / 15:56:05 / cg" |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
723 |
"Created: 22.10.1996 / 21:01:16 / cg" |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
724 |
! |
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
725 |
|
394 | 726 |
postCopy |
727 |
string := string copy. |
|
728 |
runs := runs copy |
|
307 | 729 |
! ! |
730 |
||
731 |
!Text methodsFor:'displaying'! |
|
732 |
||
963
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
733 |
displayOn:aGC x:x0 y:y opaque:opaqueWanted |
307 | 734 |
"display the receiver on a GC" |
735 |
||
1000 | 736 |
|savedFont savedPaint savedFgPaint savedBgPaint font color boldFont italicFont boldItalicFont |
737 |
bgPaint etchColor ulPaint strikePaint |
|
3158 | 738 |
wasItalic overline altFont |
702
0c2c9b9fb4aa
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
739 |
bold italic underline underwave strikeout reverse |
310 | 740 |
pos "{ Class: SmallInteger }" |
741 |
endPos "{ Class: SmallInteger }" |
|
410
3d42216e96b0
oops - x can be float in displayOn... in case of scaling in the GC
Claus Gittinger <cg@exept.de>
parents:
409
diff
changeset
|
742 |
x |
310 | 743 |
l "{ Class: SmallInteger }" |
963
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
744 |
yL k value device opaque| |
307 | 745 |
|
746 |
savedFont := aGC basicFont. |
|
747 |
savedPaint := aGC paint. |
|
315 | 748 |
savedBgPaint := aGC backgroundPaint. |
307 | 749 |
|
963
0d5ef474ea17
draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
750 |
opaque := opaqueWanted. |
705 | 751 |
device := aGC graphicsDevice. |
752 |
||
307 | 753 |
pos := 1. |
754 |
x := x0. |
|
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
755 |
bold := italic := underline := underwave := strikeout := reverse := false. |
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
756 |
|
307 | 757 |
runs runsDo:[:len :emphasis | |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
758 |
wasItalic := italic. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
759 |
color := savedPaint. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
760 |
bold := italic := underline := underwave := strikeout := reverse := false. |
3158 | 761 |
altFont := nil. |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
762 |
bgPaint := savedBgPaint. |
307 | 763 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
764 |
emphasis isSymbol ifTrue:[ |
2322 | 765 |
emphasis == BoldEmphasis ifTrue:[bold := true] |
766 |
ifFalse:[emphasis == ItalicEmphasis ifTrue:[italic := true] |
|
767 |
ifFalse:[emphasis == UnderlineEmphasis ifTrue:[underline := true] |
|
768 |
ifFalse:[emphasis == OverlineEmphasis ifTrue:[overline := true] "MB:added" |
|
769 |
ifFalse:[emphasis == UnderwaveEmphasis ifTrue:[underwave := true] |
|
770 |
ifFalse:[emphasis == StrikeoutEmphasis ifTrue:[strikeout := true] |
|
771 |
ifFalse:[emphasis == ReverseEmphasis ifTrue:[reverse := true] |
|
772 |
ifFalse:[emphasis == BoldUnderlineEmphasis ifTrue:[bold := underline := true] |
|
773 |
ifFalse:[emphasis == BoldOverlineEmphasis ifTrue:[bold := overline := true] "MB:added" |
|
774 |
ifFalse:[emphasis == BoldUnderwaveEmphasis ifTrue:[bold := underwave := true] |
|
775 |
ifFalse:[emphasis == ItalicUnderlineEmphasis ifTrue:[italic := underline := true] |
|
776 |
ifFalse:[emphasis == ItalicUnderwaveEmphasis ifTrue:[italic := underwave := true] |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
777 |
]]]]]]]]]]] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
778 |
] ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
779 |
(emphasis isMemberOf:Association) ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
780 |
value := emphasis value. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
781 |
value notNil ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
782 |
k := emphasis key. |
2322 | 783 |
k == ColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
784 |
color := value onDevice:device. |
2323 | 785 |
"/ emphasis value:color. |
2322 | 786 |
] ifFalse:[k == BackgroundColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
787 |
bgPaint := value onDevice:device. |
2323 | 788 |
"/ emphasis value:bgPaint. |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
789 |
opaque := true. |
2322 | 790 |
] ifFalse:[k == UnderlineColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
791 |
ulPaint := value onDevice:device. |
2323 | 792 |
"/ emphasis value:ulPaint. |
2322 | 793 |
] ifFalse:[k == StrikeoutColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
794 |
strikePaint := value onDevice:device. |
2323 | 795 |
"/ emphasis value:strikePaint. |
2322 | 796 |
] ifFalse:[k == EtchColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
797 |
etchColor := value onDevice:device. |
2323 | 798 |
"/ emphasis value:etchColor. |
3158 | 799 |
] ifFalse:[k == FontEmphasis ifTrue:[ |
800 |
altFont := value onDevice:device. |
|
801 |
"/ emphasis value:altFont. |
|
802 |
]]]]]] |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
803 |
] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
804 |
] ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
805 |
emphasis notNil ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
806 |
emphasis do:[:entry | |
2322 | 807 |
entry == BoldEmphasis ifTrue:[bold := true] |
808 |
ifFalse:[entry == ItalicEmphasis ifTrue:[italic := true] |
|
809 |
ifFalse:[entry == UnderlineEmphasis ifTrue:[underline := true] |
|
810 |
ifFalse:[entry == OverlineEmphasis ifTrue:[overline := true] |
|
811 |
ifFalse:[entry == UnderwaveEmphasis ifTrue:[underwave := true] |
|
812 |
ifFalse:[entry == StrikeoutEmphasis ifTrue:[strikeout := true] |
|
813 |
ifFalse:[entry == ReverseEmphasis ifTrue:[reverse := true] |
|
814 |
ifFalse:[entry == BoldUnderlineEmphasis ifTrue:[bold := underline := true] |
|
815 |
ifFalse:[emphasis == BoldUnderwaveEmphasis ifTrue:[bold := underwave := true] |
|
816 |
ifFalse:[entry == ItalicUnderlineEmphasis ifTrue:[italic := underline := true] |
|
817 |
ifFalse:[emphasis == ItalicUnderwaveEmphasis ifTrue:[italic := underwave := true] |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
818 |
ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
819 |
(entry isMemberOf:Association) ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
820 |
value := entry value. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
821 |
value notNil ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
822 |
k := entry key. |
2322 | 823 |
k == ColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
824 |
color := value onDevice:device. |
2323 | 825 |
"/ entry value:color. |
2322 | 826 |
] ifFalse:[k == BackgroundColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
827 |
bgPaint := value onDevice:device. |
2323 | 828 |
"/ entry value:bgPaint. |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
829 |
opaque := true. |
2322 | 830 |
] ifFalse:[k == UnderlineColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
831 |
ulPaint := value onDevice:device. |
2323 | 832 |
"/ entry value:ulPaint. |
2322 | 833 |
] ifFalse:[k == StrikeoutColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
834 |
strikePaint := value onDevice:device. |
2323 | 835 |
"/ entry value:strikePaint. |
2322 | 836 |
] ifFalse:[k == EtchColorEmphasis ifTrue:[ |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
837 |
etchColor := value onDevice:device. |
2323 | 838 |
"/ entry value:etchColor. |
3158 | 839 |
] ifFalse:[k == FontEmphasis ifTrue:[ |
840 |
altFont := value onDevice:device. |
|
841 |
"/ entry value:altFont. |
|
842 |
]]]]]] |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
843 |
] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
844 |
] |
2322 | 845 |
]]]]]]]]]]] |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
846 |
] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
847 |
] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
848 |
] |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
849 |
]. |
3158 | 850 |
altFont notNil ifTrue:[ |
851 |
font := altFont. |
|
852 |
] ifFalse:[ |
|
853 |
bold ifTrue:[ |
|
854 |
italic ifTrue:[ |
|
855 |
boldItalicFont isNil ifTrue:[ |
|
856 |
boldItalicFont := savedFont asBold asItalic onDevice:device |
|
857 |
]. |
|
858 |
font := boldItalicFont. |
|
859 |
] ifFalse:[ |
|
860 |
boldFont isNil ifTrue:[ |
|
861 |
boldFont := savedFont asBold onDevice:device |
|
862 |
]. |
|
863 |
font := boldFont. |
|
864 |
] |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
865 |
] ifFalse:[ |
3158 | 866 |
italic ifTrue:[ |
867 |
italicFont isNil ifTrue:[ |
|
868 |
italicFont := savedFont asItalic onDevice:device |
|
869 |
]. |
|
870 |
font := italicFont. |
|
871 |
] ifFalse:[ |
|
872 |
font := savedFont |
|
873 |
] |
|
874 |
]. |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
875 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
876 |
aGC basicFont:font. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
877 |
reverse ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
878 |
aGC paint:bgPaint on:color. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
879 |
opaque := true. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
880 |
] ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
881 |
aGC paint:color on:bgPaint. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
882 |
]. |
2323 | 883 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
884 |
endPos := pos + len - 1. |
2110 | 885 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
886 |
"/ disabled - it is too ugly (and not handled correctly, anyway). |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
887 |
"/ wasItalic ~~ italic ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
888 |
"/ italic ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
889 |
"/ "/ going from italic to non-italic; leave some space for the shear |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
890 |
"/ x := x + (font width " // 2" ) |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
891 |
"/ ]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
892 |
"/ ]. |
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
893 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
894 |
(opaque and:[etchColor isNil]) ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
895 |
aGC displayOpaqueString:string from:pos to:endPos x:x y:y. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
896 |
] ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
897 |
etchColor notNil ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
898 |
opaque ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
899 |
"/ sigh - must draw the background rectangle; |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
900 |
"/ its easier (and faster) to draw the string twice here ... |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
901 |
aGC displayOpaqueString:string from:pos to:endPos x:x y:y. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
902 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
903 |
savedFgPaint := aGC paint. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
904 |
aGC paint:etchColor. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
905 |
aGC displayString:string from:pos to:endPos x:x+1 y:y+1. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
906 |
aGC paint:savedFgPaint. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
907 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
908 |
aGC displayString:string from:pos to:endPos x:x y:y. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
909 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
910 |
l := font widthOf:string from:pos to:endPos. |
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
911 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
912 |
underline ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
913 |
ulPaint notNil ifTrue:[aGC paint:ulPaint]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
914 |
yL := y+1. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
915 |
aGC displayLineFromX:x y:yL toX:x+l-1 y:yL |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
916 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
917 |
(overline ? false) ifTrue:[ "MB:added v" |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
918 |
ulPaint notNil ifTrue:[aGC paint:ulPaint]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
919 |
yL := y-(font heightOf: string) + 2. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
920 |
aGC displayLineFromX:x y:yL toX:x+l-1 y:yL |
2322 | 921 |
]. "MB:added ^" |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
922 |
underwave ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
923 |
ulPaint notNil ifTrue:[aGC paint:ulPaint]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
924 |
yL := y+1. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
925 |
aGC displayHorizontalWavelineFromX:x y:yL toX:x+l-1 |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
926 |
]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
927 |
strikeout ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
928 |
strikePaint notNil ifTrue:[aGC paint:strikePaint]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
929 |
yL := y-(font ascent//2). |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
930 |
aGC displayLineFromX:x y:yL toX:x+l-1 y:yL |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
931 |
]. |
307 | 932 |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
933 |
x := x + l. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
934 |
pos := endPos + 1 |
304 | 935 |
]. |
307 | 936 |
|
937 |
aGC basicFont:savedFont. |
|
316 | 938 |
aGC paint:savedPaint on:savedBgPaint. |
307 | 939 |
|
591
dfa5c6178f6d
care to use deviceFont in width-query
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
940 |
"Created: / 12.5.1996 / 11:14:30 / cg" |
761 | 941 |
"Modified: / 7.7.1999 / 00:08:12 / cg" |
304 | 942 |
! ! |
943 |
||
944 |
!Text methodsFor:'emphasis'! |
|
945 |
||
2128 | 946 |
actionForAll:aBlock |
2311
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
947 |
"change the actionBlock of all characters. |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
948 |
Some widgets use this like a href if clicked onto the text." |
2128 | 949 |
|
950 |
self emphasisAllAdd:(#actionBlock -> aBlock). |
|
951 |
||
2311
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
952 |
"transcript ignores this... |
2128 | 953 |
Transcript showCR: |
2311
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
954 |
((Text string:'hello - click on me') actionForAll:[Transcript flash]) |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
955 |
" |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
956 |
|
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
957 |
"labels also... |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
958 |
Label new |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
959 |
label: ((Text string:'hello - click on me') actionForAll:[Transcript flash]); |
ffc769e95190
comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents:
2305
diff
changeset
|
960 |
open |
2128 | 961 |
" |
962 |
! |
|
963 |
||
304 | 964 |
allBold |
965 |
"make all characters bold" |
|
966 |
||
2852 | 967 |
self emphasisAllAdd:BoldEmphasis |
304 | 968 |
|
969 |
" |
|
970 |
(Text string:'hello') allBold |
|
2056 | 971 |
Transcript showCR: ('hello' allBold) |
304 | 972 |
" |
973 |
||
406 | 974 |
"Modified: 10.7.1996 / 12:07:51 / cg" |
304 | 975 |
! |
976 |
||
2110 | 977 |
allBoldOverline |
2322 | 978 |
"make all characters bold and overline" |
2110 | 979 |
|
2852 | 980 |
self emphasisAllAdd:BoldOverlineEmphasis |
2110 | 981 |
! |
982 |
||
734 | 983 |
allItalic |
984 |
"make all characters italic" |
|
985 |
||
2852 | 986 |
self emphasisAllAdd:ItalicEmphasis |
734 | 987 |
|
988 |
" |
|
989 |
(Text string:'hello') allItalic |
|
2056 | 990 |
Transcript showCR: ('hello' allItalic) |
734 | 991 |
" |
992 |
||
993 |
"Modified: 10.7.1996 / 12:07:51 / cg" |
|
994 |
! |
|
995 |
||
3472 | 996 |
allNonBold |
997 |
"make all characters non-bold" |
|
998 |
||
999 |
self emphasisAllRemove:BoldEmphasis |
|
1000 |
||
1001 |
" |
|
1002 |
(Text string:'hello') allBold allNonBold |
|
1003 |
" |
|
1004 |
! |
|
1005 |
||
2110 | 1006 |
allOverline |
1007 |
"make all characters overline" |
|
1008 |
||
2852 | 1009 |
self emphasisAllAdd:OverlineEmphasis |
2322 | 1010 |
|
1011 |
" |
|
1012 |
Transcript showCR: ('hello' asText allOverline) |
|
1013 |
" |
|
2110 | 1014 |
! |
1015 |
||
2056 | 1016 |
allStrikedOut |
1017 |
"strikeOut all characters" |
|
1018 |
||
2322 | 1019 |
self emphasisAllAdd:StrikeoutEmphasis. |
2056 | 1020 |
|
1021 |
" |
|
1022 |
Transcript showCR: ('hello' allStrikedOut) |
|
1023 |
" |
|
1024 |
! |
|
1025 |
||
1020
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1026 |
allUnderlined |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1027 |
"underline all characters" |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1028 |
|
2322 | 1029 |
self emphasisAllAdd:UnderlineEmphasis. |
1020
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1030 |
|
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1031 |
" |
2056 | 1032 |
Transcript showCR:('hello' allUnderlined) |
1020
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1033 |
" |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1034 |
! |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1035 |
|
2322 | 1036 |
allUnderwaved |
1037 |
"underwave all characters" |
|
1038 |
||
1039 |
self emphasisAllAdd:UnderwaveEmphasis. |
|
1040 |
||
1041 |
" |
|
1042 |
Transcript showCR:('hello' asText allUnderwaved) |
|
1043 |
" |
|
1044 |
! |
|
1045 |
||
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1046 |
backgroundColorizeAllWith:aColor |
2552
a891a2d361b8
comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents:
2496
diff
changeset
|
1047 |
"change the bg-color of all characters" |
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1048 |
|
2322 | 1049 |
self emphasisAllAdd:(BackgroundColorEmphasis -> aColor). |
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1050 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1051 |
" |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1052 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1053 |
((Text string:'hello') backgroundColorizeAllWith:(Color red)) |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1054 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1055 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1056 |
('hello' allBold backgroundColorizeAllWith:(Color red)) |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1057 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1058 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1059 |
('hello' asText backgroundColorizeAllWith:(Color red)) |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1060 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1061 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1062 |
('hello ' , ('red' allBold backgroundColorizeAllWith:(Color red)) , ' world') |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1063 |
" |
2552
a891a2d361b8
comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents:
2496
diff
changeset
|
1064 |
|
a891a2d361b8
comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents:
2496
diff
changeset
|
1065 |
"Modified: / 01-04-2011 / 16:19:21 / cg" |
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1066 |
! |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1067 |
|
999 | 1068 |
colorizeAllWith:aColor |
1069 |
"change the color of all characters" |
|
1070 |
||
2322 | 1071 |
self emphasisAllAdd:(ColorEmphasis -> aColor). |
999 | 1072 |
|
1073 |
" |
|
1074 |
Transcript showCR: |
|
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1075 |
((Text string:'hello') colorizeAllWith:(Color red)) |
999 | 1076 |
|
1077 |
Transcript showCR: |
|
2056 | 1078 |
('hello' colorizeAllWith:(Color red)) |
1079 |
||
1080 |
Transcript showCR: |
|
1019
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1081 |
('hello' allBold colorizeAllWith:(Color red)) |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1082 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1083 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1084 |
('hello' asText colorizeAllWith:(Color red)) |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1085 |
|
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1086 |
Transcript showCR: |
38ec486889d9
colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
1087 |
('hello ' , ('red' allBold colorizeAllWith:(Color red)) , ' world') |
999 | 1088 |
" |
1089 |
! |
|
1090 |
||
2312
ab6ab043d9ca
comment/format in: #colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1091 |
colorizeAllWith:fgColor on:bgColor |
1648 | 1092 |
"change the color and bg-color of all characters" |
1093 |
||
2322 | 1094 |
self emphasisAllAdd:(ColorEmphasis -> fgColor). |
1095 |
self emphasisAllAdd:(BackgroundColorEmphasis -> bgColor). |
|
1648 | 1096 |
|
1097 |
" |
|
1098 |
Transcript showCR: |
|
2312
ab6ab043d9ca
comment/format in: #colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
1099 |
((Text string:'hello') colorizeAllWith:(Color blue) on:(Color yellow)) |
1648 | 1100 |
" |
1101 |
||
1102 |
"Created: / 05-08-2006 / 14:48:13 / cg" |
|
1103 |
! |
|
1104 |
||
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1105 |
emphasis |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1106 |
"return the emphasis" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1107 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1108 |
^ runs |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1109 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1110 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1111 |
(Text string:'hello') allBold emphasis |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1112 |
'hello' emphasis |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1113 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1114 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1115 |
"Modified: 11.5.1996 / 14:22:31 / cg" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1116 |
"Created: 14.5.1996 / 13:59:03 / cg" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1117 |
! |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1118 |
|
1070 | 1119 |
emphasis:emArray |
1120 |
1 to:string size do:[:characterIndex | |
|
1121 |
self emphasisAt:characterIndex put:(emArray at:characterIndex) |
|
1122 |
]. |
|
1123 |
||
1124 |
" |
|
1125 |
(Text string:'hello') emphasis:#(italic bold italic bold bold) |
|
1126 |
" |
|
1127 |
||
1128 |
"Modified: / 31.3.1998 / 16:45:14 / cg" |
|
1129 |
! |
|
1130 |
||
778 | 1131 |
emphasisAllAdd:newEmphasis |
1132 |
"add to the emphasis to all characters. return the receiver" |
|
1133 |
||
3116 | 1134 |
runs isNil ifTrue:[ ^ self ]. "/ just in case: empty |
1135 |
||
1136 |
(runs conform:[:runValue | runValue isNil]) ifTrue:[ |
|
1137 |
"/ no emphasis - happens often |
|
1138 |
runs atAllPut:newEmphasis. |
|
1139 |
] ifFalse:[ |
|
1140 |
self emphasisFrom:1 to:(self size) add:newEmphasis |
|
1141 |
]. |
|
778 | 1142 |
|
1143 |
" |
|
1144 |
(Text string:'hello') allBold |
|
1145 |
emphasisAllAdd:#italic |
|
1146 |
||
1147 |
Transcript show:((Text string:'hello') allBold |
|
1148 |
emphasisAllAdd:#italic) |
|
1149 |
" |
|
1150 |
! |
|
1151 |
||
1152 |
emphasisAllRemove:anEmphasis |
|
1153 |
"remove the emphasis from all characters. return the receiver" |
|
1154 |
||
1155 |
self emphasisFrom:1 to:(self size) remove:anEmphasis |
|
1156 |
||
1157 |
" |
|
1158 |
((Text string:'hello') emphasizeAllWith:#(bold italic)) |
|
1159 |
emphasisAllRemove:#italic |
|
1160 |
||
834
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1161 |
((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1162 |
with:#italic)) |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1163 |
emphasisAllRemove:#italic |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1164 |
|
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1165 |
((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1166 |
with:#italic)) |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1167 |
emphasisAllRemove:#color |
08c8f9d9ca0a
fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
1168 |
|
778 | 1169 |
Transcript show:(((Text string:'hello') emphasizeAllWith:#(bold italic)) |
1170 |
emphasisAllRemove:#italic) |
|
1171 |
" |
|
1172 |
! |
|
1173 |
||
304 | 1174 |
emphasisAt:characterIndex |
1175 |
"return the emphasis at some index" |
|
1176 |
||
1177 |
^ runs at:characterIndex |
|
1178 |
||
1179 |
" |
|
1180 |
(Text string:'hello') allBold emphasisAt:2 |
|
1181 |
" |
|
1182 |
||
1183 |
"Modified: 11.5.1996 / 14:22:31 / cg" |
|
1184 |
! |
|
1185 |
||
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1186 |
emphasisAt:characterIndex add:newEmphasis |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1187 |
"add to the emphasis at some index. return the receiver" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1188 |
|
626 | 1189 |
|e prevE| |
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1190 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1191 |
e := runs at:characterIndex. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1192 |
e := self class addEmphasis:newEmphasis to:e. |
626 | 1193 |
|
1194 |
"/ if its equal to the previous emphasis, make it identical. |
|
1195 |
||
1196 |
characterIndex > 1 ifTrue:[ |
|
1197 |
prevE := runs at:characterIndex-1. |
|
1198 |
e = prevE ifTrue:[ |
|
1199 |
e := prevE |
|
1200 |
] |
|
1201 |
]. |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1202 |
runs at:characterIndex put:e |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1203 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1204 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1205 |
(Text string:'hello') allBold emphasisAt:2 add:#italic |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1206 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1207 |
|
626 | 1208 |
"Created: / 14.5.1996 / 16:48:39 / cg" |
1209 |
"Modified: / 31.3.1998 / 15:29:14 / cg" |
|
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1210 |
! |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1211 |
|
307 | 1212 |
emphasisAt:characterIndex put:emphasis |
1213 |
"change the emphasis at some index. return the receiver" |
|
1214 |
||
626 | 1215 |
|e prevE| |
1216 |
||
1217 |
e := emphasis. |
|
1218 |
||
1219 |
"/ if its equal to the previous emphasis, make it identical. |
|
1220 |
||
1221 |
characterIndex > 1 ifTrue:[ |
|
1222 |
prevE := runs at:characterIndex-1. |
|
1223 |
emphasis = prevE ifTrue:[ |
|
1224 |
e := prevE |
|
1225 |
] |
|
1226 |
]. |
|
1227 |
runs at:characterIndex put:e |
|
307 | 1228 |
|
1229 |
" |
|
1230 |
(Text string:'hello') allBold emphasisAt:2 put:#italic |
|
1231 |
" |
|
1232 |
||
626 | 1233 |
"Modified: / 31.3.1998 / 16:45:14 / cg" |
307 | 1234 |
! |
1235 |
||
336
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1236 |
emphasisAt:characterIndex remove:emphasisToRemove |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1237 |
"remove from the emphasis at some index. return the receiver" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1238 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1239 |
|e| |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1240 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1241 |
e := runs at:characterIndex. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1242 |
e := self class removeEmphasis:emphasisToRemove from:e. |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1243 |
runs at:characterIndex put:e |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1244 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1245 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1246 |
(Text string:'hello') |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1247 |
allBold emphasisAt:2 remove:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1248 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1249 |
(Text string:'hello' emphasis:#(bold italic)) |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1250 |
emphasisAt:2 remove:#bold |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1251 |
" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1252 |
|
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1253 |
"Created: 14.5.1996 / 16:48:39 / cg" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1254 |
"Modified: 14.5.1996 / 17:25:04 / cg" |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1255 |
! |
5fd5fcc38eaa
helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1256 |
|
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1257 |
emphasisCollection |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1258 |
"return the emphasis" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1259 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1260 |
^ runs |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1261 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1262 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1263 |
(Text string:'hello') allBold emphasis |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1264 |
'hello' emphasis |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1265 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1266 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1267 |
"Created: 14.5.1996 / 13:59:03 / cg" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1268 |
"Modified: 14.5.1996 / 15:02:11 / cg" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1269 |
! |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1270 |
|
777 | 1271 |
emphasisFrom:start to:stop add:newEmphasis |
1272 |
"add to the emphasis within some range. return the receiver" |
|
1273 |
||
1274 |
start to:stop do:[:characterIndex | |
|
1275 |
self emphasisAt:characterIndex add:newEmphasis |
|
1276 |
]. |
|
1277 |
||
1278 |
" |
|
1279 |
(Text string:'hello') allBold |
|
1280 |
emphasisFrom:2 to:4 add:#italic |
|
1281 |
||
1282 |
Transcript showCR:((Text string:'hello') allBold |
|
1283 |
emphasisFrom:2 to:4 add:#italic) |
|
1284 |
||
1285 |
" |
|
1286 |
! |
|
1287 |
||
1288 |
emphasisFrom:start to:stop remove:anEmphasis |
|
1289 |
"remove from the emphasis within some range. return the receiver" |
|
1290 |
||
1291 |
start to:stop do:[:characterIndex | |
|
1292 |
self emphasisAt:characterIndex remove:anEmphasis |
|
1293 |
]. |
|
1294 |
||
1295 |
" |
|
1296 |
(Text string:'hello') allBold |
|
1297 |
emphasisFrom:2 to:4 remove:#bold |
|
1298 |
||
1299 |
Transcript showCR:((Text string:'hello') allBold |
|
1300 |
emphasisFrom:2 to:4 remove:#bold) |
|
1301 |
" |
|
1302 |
! |
|
1303 |
||
2240 | 1304 |
emphasiseFrom:start to:stop with:newEmphasis |
1305 |
"set to the emphasis within some range. return the receiver" |
|
1306 |
||
1307 |
start to:stop do:[:characterIndex | |
|
1308 |
self emphasisAt:characterIndex put:newEmphasis |
|
1309 |
]. |
|
1310 |
||
1311 |
" |
|
1312 |
(Text string:'hello') allBold |
|
1313 |
emphasiseFrom:2 to:4 with:#italic |
|
1314 |
||
1315 |
Transcript showCR:((Text string:'hello') allBold |
|
1316 |
emphasiseFrom:2 to:4 with:#italic) |
|
1317 |
||
1318 |
" |
|
1319 |
! |
|
1320 |
||
304 | 1321 |
emphasizeAllWith:emphasis |
1322 |
"change the emphasis of all characters" |
|
1323 |
||
1324 |
runs := RunArray new:(string size) withAll:emphasis |
|
1325 |
||
1326 |
" |
|
1327 |
(Text string:'hello') allBold emphasizeAllWith:#italic |
|
1328 |
" |
|
1329 |
||
1330 |
"Modified: 11.5.1996 / 14:22:52 / cg" |
|
1331 |
! |
|
1332 |
||
343 | 1333 |
emphasizeFrom:start count:count with:emphasis |
1334 |
"change the emphasis of a range of characters, given startIndex and count." |
|
1335 |
||
1336 |
self emphasizeFrom:start to:(start+count-1) with:emphasis |
|
1337 |
||
1338 |
" |
|
1339 |
(Text string:'hello world') |
|
1340 |
emphasizeFrom:1 count:5 with:#bold; |
|
1341 |
emphasizeFrom:7 count:5 with:#italic |
|
1342 |
" |
|
1343 |
||
1344 |
"Modified: 11.5.1996 / 14:30:02 / cg" |
|
1345 |
"Created: 16.5.1996 / 10:52:27 / cg" |
|
1346 |
! |
|
1347 |
||
304 | 1348 |
emphasizeFrom:start to:stop with:emphasis |
1349 |
"change the emphasis of a range of characters" |
|
1350 |
||
3010 | 1351 |
"/ |newRuns| |
304 | 1352 |
|
631 | 1353 |
runs from:start to:stop put:emphasis. |
626 | 1354 |
|
777 | 1355 |
"/ newRuns := RunArray new. |
1356 |
"/ |
|
1357 |
"/ "/ for now - a q&d hack |
|
1358 |
"/ 1 to:start-1 do:[:i | |
|
1359 |
"/ newRuns add:(runs at:i). |
|
1360 |
"/ ]. |
|
1361 |
"/ newRuns add:emphasis withOccurrences:(stop - start + 1). |
|
1362 |
"/ stop+1 to:string size do:[:i | |
|
1363 |
"/ newRuns add:(runs at:i) |
|
1364 |
"/ ]. |
|
1365 |
"/ runs := newRuns |
|
304 | 1366 |
|
1367 |
" |
|
1368 |
(Text string:'hello world') |
|
1369 |
emphasizeFrom:1 to:5 with:#bold; |
|
1370 |
emphasizeFrom:7 to:11 with:#italic |
|
1371 |
" |
|
1372 |
||
631 | 1373 |
"Modified: / 7.4.1998 / 08:52:18 / cg" |
347 | 1374 |
! |
1375 |
||
1376 |
emphasizeFrom:start with:emphasis |
|
1377 |
"change the emphasis of some characters upTo the end" |
|
1378 |
||
1379 |
self emphasizeFrom:start to:(self size) with:emphasis |
|
1380 |
||
1381 |
" |
|
1382 |
(Text string:'hello world') |
|
1383 |
emphasizeFrom:1 count:5 with:#bold; |
|
1384 |
emphasizeFrom:7 with:#italic |
|
1385 |
" |
|
1386 |
||
1387 |
"Modified: 11.5.1996 / 14:30:02 / cg" |
|
1388 |
"Created: 17.5.1996 / 15:15:32 / cg" |
|
1020
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1389 |
! |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1390 |
|
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1391 |
strikeoutAll |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1392 |
"strikeout all characters" |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1393 |
|
2322 | 1394 |
self emphasisAllAdd:StrikeoutEmphasis. |
1020
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1395 |
|
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1396 |
" |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1397 |
Transcript showCR: |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1398 |
('hello' asText strikeoutAll) |
a6304ef6b18a
more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1399 |
" |
1069 | 1400 |
! |
1401 |
||
3248 | 1402 |
withColor:aColor |
1403 |
"change the color of all characters" |
|
1404 |
||
1405 |
self emphasisAllAdd:(ColorEmphasis -> aColor). |
|
1406 |
||
1407 |
" |
|
1408 |
Transcript showCR: |
|
1409 |
((Text string:'hello') colorizeAllWith:(Color red)) |
|
1410 |
||
1411 |
Transcript showCR: |
|
1412 |
('hello' colorizeAllWith:(Color red)) |
|
1413 |
||
1414 |
Transcript showCR: |
|
1415 |
('hello' allBold colorizeAllWith:(Color red)) |
|
1416 |
||
1417 |
Transcript showCR: |
|
1418 |
('hello' asText colorizeAllWith:(Color red)) |
|
1419 |
||
1420 |
Transcript showCR: |
|
1421 |
('hello ' , ('red' allBold colorizeAllWith:(Color red)) , ' world') |
|
1422 |
" |
|
1423 |
! |
|
1424 |
||
2322 | 1425 |
withoutAnyColorEmphasis |
1426 |
^ (self withoutEmphasis:BackgroundColorEmphasis) withoutEmphasis:ColorEmphasis |
|
1427 |
! |
|
1428 |
||
1429 |
withoutBackgroundColorEmphasis |
|
1430 |
^ self withoutEmphasis:BackgroundColorEmphasis |
|
1431 |
! |
|
1432 |
||
1069 | 1433 |
withoutEmphasis:emphasisToRemove |
2322 | 1434 |
|newText anyEmphasis| |
1069 | 1435 |
|
1436 |
self hasChangeOfEmphasis ifTrue:[ |
|
1437 |
newText := self copyFrom:1 to:self size. |
|
2322 | 1438 |
anyEmphasis := false. |
1069 | 1439 |
1 to:newText size do:[:col | |
1440 |
|em newem| |
|
1441 |
||
1442 |
em := (newText emphasis) at:col. |
|
1443 |
em notNil ifTrue:[ |
|
1444 |
newem := Text removeEmphasis:emphasisToRemove from:em. |
|
1445 |
newem ~~ em ifTrue:[ |
|
2322 | 1446 |
newText emphasisAt:col put:newem. |
2323 | 1447 |
]. |
1448 |
newem notNil ifTrue:[ anyEmphasis := true ]. |
|
1069 | 1449 |
]. |
1450 |
]. |
|
2322 | 1451 |
anyEmphasis ifFalse:[^ newText string]. |
1069 | 1452 |
^ newText |
1453 |
]. |
|
1454 |
^ self |
|
2322 | 1455 |
! |
1456 |
||
1457 |
withoutForegroundColorEmphasis |
|
1458 |
^ self withoutEmphasis:ColorEmphasis |
|
304 | 1459 |
! ! |
1460 |
||
1757 | 1461 |
|
304 | 1462 |
!Text methodsFor:'printing & storing'! |
1463 |
||
2128 | 1464 |
displayOn:aGCOrStream |
1465 |
"append a printed representation from which the receiver can be reconstructed |
|
1466 |
to aStream." |
|
1467 |
||
1468 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
|
1469 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
|
3325 | 1470 |
(aGCOrStream isStream) ifTrue:[ |
2128 | 1471 |
aGCOrStream nextPutAll:'(Text string:'. |
1472 |
string storeOn:aGCOrStream. |
|
1473 |
aGCOrStream nextPutAll:' runs:'. |
|
1474 |
runs displayOn:aGCOrStream. |
|
1475 |
aGCOrStream nextPutAll:')'. |
|
1476 |
^ self. |
|
1477 |
]. |
|
1478 |
^ self displayOn:aGCOrStream x:0 y:0. |
|
1479 |
||
1480 |
"Created: 11.5.1996 / 14:27:09 / cg" |
|
1481 |
"Modified: 16.5.1996 / 11:23:32 / cg" |
|
1482 |
! |
|
1483 |
||
3273 | 1484 |
displayString |
1485 |
"return a string used when displaying the receiver in a view." |
|
1486 |
||
1487 |
^ self. |
|
1488 |
! |
|
1489 |
||
343 | 1490 |
printOn:aStream |
1491 |
"print the receivers characters (including emphasis) on |
|
409 | 1492 |
aStream. |
1077 | 1493 |
Notice, that some streams simply ignore the emphasis" |
343 | 1494 |
|
2051 | 1495 |
aStream nextPutAllText:self |
304 | 1496 |
|
343 | 1497 |
" |
407 | 1498 |
Transcript showCR:'hello world'. |
1499 |
Transcript showCR:'hello world' asText allBold. |
|
1500 |
Transcript showCR:('hello world' asText emphasizeAllWith:#italic). |
|
343 | 1501 |
" |
304 | 1502 |
|
409 | 1503 |
"Modified: 12.7.1996 / 10:15:47 / cg" |
304 | 1504 |
! |
1505 |
||
1506 |
storeOn:aStream |
|
343 | 1507 |
"append a printed representation from which the receiver can be reconstructed |
1508 |
to aStream." |
|
1509 |
||
304 | 1510 |
aStream nextPutAll:'(Text string:'. |
1511 |
string storeOn:aStream. |
|
307 | 1512 |
aStream nextPutAll:' runs:'. |
304 | 1513 |
runs storeOn:aStream. |
1514 |
aStream nextPutAll:')'. |
|
1515 |
||
1516 |
"Created: 11.5.1996 / 14:27:09 / cg" |
|
343 | 1517 |
"Modified: 16.5.1996 / 11:23:32 / cg" |
304 | 1518 |
! ! |
1519 |
||
1200 | 1520 |
!Text methodsFor:'private-accessing'! |
304 | 1521 |
|
631 | 1522 |
emphasisCollection:emphasisCollection |
1523 |
"set the string and emphasis collection. |
|
1524 |
The emphasis collection contains per-character information." |
|
1525 |
||
1526 |
runs := emphasisCollection |
|
1527 |
||
1528 |
"Created: / 7.4.1998 / 08:52:03 / cg" |
|
1529 |
! |
|
1530 |
||
2959 | 1531 |
runs |
1532 |
^ runs |
|
1533 |
! |
|
1534 |
||
3009 | 1535 |
setRuns:anArrayOrRunArray |
1536 |
runs := anArrayOrRunArray |
|
1537 |
! |
|
1538 |
||
1539 |
setString:aString setRuns:anArrayOrRunArray |
|
872
2ca6864d13bb
new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents:
854
diff
changeset
|
1540 |
string := aString. |
3009 | 1541 |
runs := anArrayOrRunArray |
872
2ca6864d13bb
new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents:
854
diff
changeset
|
1542 |
! |
2ca6864d13bb
new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents:
854
diff
changeset
|
1543 |
|
304 | 1544 |
string:aString emphasis:emphasis |
343 | 1545 |
"set the string and emphasis. The emphasis is applied to all characters." |
1546 |
||
428 | 1547 |
string := aString string. |
1548 |
runs := RunArray new:string size withAll:emphasis |
|
304 | 1549 |
|
1550 |
" |
|
1551 |
|t| |
|
1552 |
||
1553 |
t := Text new string:'hello' emphasis:#bold. |
|
1554 |
t emphasisAt:2. |
|
1555 |
" |
|
1556 |
||
343 | 1557 |
"Modified: 16.5.1996 / 11:24:03 / cg" |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1558 |
! |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1559 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1560 |
string:aString emphasisCollection:emphasisCollection |
343 | 1561 |
"set the string and emphasis collection. |
1562 |
The emphasis collection contains per-character information." |
|
1563 |
||
428 | 1564 |
string := aString string. |
1160 | 1565 |
string size == 0 ifTrue:[ |
1566 |
runs := RunArray new. |
|
1567 |
] ifFalse:[ |
|
1568 |
runs := emphasisCollection asRunArray |
|
1569 |
]. |
|
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1570 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1571 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1572 |
|t| |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1573 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1574 |
t := Text new string:'hello' emphasisCollection:(#bold #bold #bold #italic #italic). |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1575 |
t emphasisAt:2. |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1576 |
" |
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1577 |
|
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1578 |
"Created: 14.5.1996 / 14:03:29 / cg" |
343 | 1579 |
"Modified: 16.5.1996 / 11:24:21 / cg" |
304 | 1580 |
! ! |
1581 |
||
1582 |
!Text methodsFor:'queries'! |
|
1583 |
||
2128 | 1584 |
emphasisAtPoint:aPoint on:aGC |
1585 |
"return the emphasis at a given point, or nil if there is none" |
|
1586 |
||
1587 |
|pointX savedFont boldFont italicFont bold italic wasItalic pos f l device posX| |
|
1588 |
||
1589 |
pointX := aPoint x. |
|
1590 |
device := aGC graphicsDevice. |
|
1591 |
||
1592 |
savedFont := aGC basicFont onDevice:device. |
|
1593 |
||
1594 |
pos := 1. |
|
1595 |
posX := 0. |
|
1596 |
l := 0. |
|
1597 |
italic := false. |
|
1598 |
runs runsDo:[:len :emphasis | |
|
1599 |
wasItalic := italic. |
|
1600 |
emphasis isSymbol ifTrue:[ |
|
1601 |
bold := (emphasis == #bold). |
|
1602 |
italic := (emphasis == #italic). |
|
1603 |
] ifFalse:[ |
|
1604 |
(emphasis isNil |
|
1605 |
or:[emphasis isMemberOf:Association]) ifTrue:[ |
|
1606 |
bold := italic := false |
|
1607 |
] ifFalse:[ |
|
1608 |
bold := emphasis includesIdentical:#bold. |
|
1609 |
italic := emphasis includesIdentical:#italic. |
|
1610 |
] |
|
1611 |
]. |
|
1612 |
||
1613 |
bold ifTrue:[ |
|
1614 |
boldFont isNil ifTrue:[ |
|
1615 |
boldFont := savedFont asBold onDevice:device |
|
1616 |
]. |
|
1617 |
f := boldFont. |
|
1618 |
] ifFalse:[ |
|
1619 |
italic ifTrue:[ |
|
1620 |
italicFont isNil ifTrue:[ |
|
1621 |
italicFont := savedFont asItalic onDevice:device |
|
1622 |
]. |
|
1623 |
f := italicFont |
|
1624 |
] ifFalse:[ |
|
1625 |
f := savedFont |
|
1626 |
] |
|
1627 |
]. |
|
1628 |
f := f onDevice:device. |
|
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1629 |
"/ disabled - it is too ugly (and not handled correctly, anyway). |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1630 |
"/ wasItalic ~~ italic ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1631 |
"/ italic ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1632 |
"/ "/ going from italic to non-italic; leave some space for the shear |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1633 |
"/ l := l + (f width " // 2" ) |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1634 |
"/ ]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1635 |
"/ ]. |
2128 | 1636 |
l := (f widthOf:string from:pos to:(pos + len - 1)). |
1637 |
(pointX between:posX and:posX + l) ifTrue:[ |
|
1638 |
^ emphasis |
|
1639 |
]. |
|
1640 |
pos := pos + len. |
|
1641 |
posX := posX + l. |
|
1642 |
]. |
|
1643 |
||
1644 |
^ nil |
|
1645 |
! |
|
1646 |
||
1401 | 1647 |
encoding |
1648 |
^ string encoding |
|
1649 |
! |
|
1650 |
||
304 | 1651 |
hasChangeOfEmphasis |
2830
b69f6dc901f0
comment/format in: #hasChangeOfEmphasis
Claus Gittinger <cg@exept.de>
parents:
2734
diff
changeset
|
1652 |
"return true, if the receiver contains non-empty emphasis information |
b69f6dc901f0
comment/format in: #hasChangeOfEmphasis
Claus Gittinger <cg@exept.de>
parents:
2734
diff
changeset
|
1653 |
i.e. any non-normal (=emphasized) characters" |
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1654 |
|
3472 | 1655 |
^ runs notEmptyOrNil |
1656 |
and:[ runs contains:[:e | e notNil] ] |
|
304 | 1657 |
|
1658 |
"Created: 11.5.1996 / 14:03:19 / cg" |
|
335
4adf1b6b4063
concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1659 |
"Modified: 14.5.1996 / 15:51:01 / cg" |
304 | 1660 |
! |
1661 |
||
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1662 |
hasEmphasis: emphasis |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1663 |
"return true, if the receiver contains given emphasis" |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1664 |
|
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1665 |
"HACK!!!!!!" |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1666 |
|
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1667 |
| emphasisArray | |
2675 | 1668 |
|
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1669 |
(emphasis isSymbol or:[emphasis isAssociation]) ifTrue:[ |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1670 |
emphasisArray := Array with: emphasis |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1671 |
] ifFalse:[ |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1672 |
emphasisArray := emphasis. |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1673 |
]. |
2675 | 1674 |
emphasisArray isNil ifTrue:[^false]. |
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1675 |
|
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1676 |
runs do:[:runEmph| |
3116 | 1677 |
emphasisArray do:[:searchEmph| |
1678 |
(runEmph = searchEmph |
|
1679 |
or: [runEmph isCollection |
|
1680 |
and:[runEmph isSymbol not |
|
1681 |
and:[runEmph includes: searchEmph]]] |
|
1682 |
) ifTrue:[ |
|
1683 |
^ true |
|
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1684 |
] |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1685 |
] |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1686 |
]. |
3116 | 1687 |
^ false |
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1688 |
|
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1689 |
" |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1690 |
'Hello' asText allBold hasEmphasis: #bold. |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1691 |
'Hello' asText allBold allUnderlined hasEmphasis: #bold. |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1692 |
'Hello' asText allBold allUnderlined hasEmphasis: #italic. |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1693 |
('Hello' asText allBold allUnderlined , ' World' asText allItalic) hasEmphasis: #italic. |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1694 |
" |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1695 |
|
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1696 |
"Created: / 20-07-2011 / 17:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2675 | 1697 |
"Modified (format): / 18-11-2011 / 14:55:10 / cg" |
2578
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1698 |
! |
0b44903b0406
Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2552
diff
changeset
|
1699 |
|
307 | 1700 |
heightOn:aGC |
1701 |
"return the number of device units, required on aGC's device" |
|
1702 |
||
621 | 1703 |
^ (aGC font onDevice:aGC device) heightOf:string |
307 | 1704 |
|
1705 |
"Created: 12.5.1996 / 11:02:03 / cg" |
|
1706 |
! |
|
1707 |
||
304 | 1708 |
indexOf:aCharacter startingAt:index |
343 | 1709 |
"search aCharacters index in the underlying string" |
1710 |
||
304 | 1711 |
^ string indexOf:aCharacter startingAt:index |
1712 |
||
1713 |
"Created: 11.5.1996 / 13:58:56 / cg" |
|
343 | 1714 |
"Modified: 16.5.1996 / 11:25:12 / cg" |
304 | 1715 |
! |
1716 |
||
307 | 1717 |
isText |
343 | 1718 |
"return true if this is a Text object - always true here" |
1719 |
||
307 | 1720 |
^ true |
1721 |
||
1722 |
"Created: 12.5.1996 / 10:56:24 / cg" |
|
343 | 1723 |
"Modified: 16.5.1996 / 11:25:29 / cg" |
307 | 1724 |
! |
1725 |
||
304 | 1726 |
occurrencesOf:aCharacter |
343 | 1727 |
"count & return the number of occurrences of aCharacter in the |
1728 |
underlying string" |
|
1729 |
||
304 | 1730 |
^ string occurrencesOf:aCharacter |
1731 |
||
1732 |
"Created: 11.5.1996 / 13:58:46 / cg" |
|
343 | 1733 |
"Modified: 16.5.1996 / 11:25:51 / cg" |
304 | 1734 |
! |
1735 |
||
1736 |
size |
|
343 | 1737 |
"return the number of characters in the underlying string" |
1738 |
||
304 | 1739 |
^ string size |
1740 |
||
1741 |
"Created: 11.5.1996 / 14:25:15 / cg" |
|
343 | 1742 |
"Modified: 16.5.1996 / 11:26:08 / cg" |
304 | 1743 |
! |
1744 |
||
1745 |
string |
|
343 | 1746 |
"return the receiver without any emphasis information |
1747 |
i.e. the underlying string." |
|
1748 |
||
304 | 1749 |
^ string |
1750 |
||
1751 |
"Created: 11.5.1996 / 13:58:38 / cg" |
|
343 | 1752 |
"Modified: 16.5.1996 / 11:26:30 / cg" |
307 | 1753 |
! |
1754 |
||
1069 | 1755 |
widthFrom:startIndex to:endIndex on:aGC |
1756 |
"return the number of device units, required on aGC's device" |
|
1757 |
||
1758 |
^ (self copyFrom:startIndex to:endIndex) widthOn:aGC |
|
1759 |
! |
|
1760 |
||
307 | 1761 |
widthOn:aGC |
1762 |
"return the number of device units, required on aGC's device" |
|
1763 |
||
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
1764 |
|savedFont boldFont italicFont bold italic wasItalic pos f l device| |
307 | 1765 |
|
404
14cf34141532
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
1766 |
device := aGC graphicsDevice. |
14cf34141532
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
1767 |
|
794 | 1768 |
savedFont := aGC basicFont onDevice:device. |
307 | 1769 |
|
1770 |
pos := 1. |
|
1771 |
l := 0. |
|
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
1772 |
italic := false. |
307 | 1773 |
runs runsDo:[:len :emphasis | |
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
1774 |
wasItalic := italic. |
307 | 1775 |
emphasis isSymbol ifTrue:[ |
975
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
1776 |
bold := (emphasis == #bold). |
4a2048f291eb
care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
1777 |
italic := (emphasis == #italic). |
307 | 1778 |
] ifFalse:[ |
308 | 1779 |
(emphasis isNil |
1780 |
or:[emphasis isMemberOf:Association]) ifTrue:[ |
|
307 | 1781 |
bold := italic := false |
1782 |
] ifFalse:[ |
|
1783 |
bold := emphasis includesIdentical:#bold. |
|
1784 |
italic := emphasis includesIdentical:#italic. |
|
1785 |
] |
|
1786 |
]. |
|
1787 |
||
1788 |
bold ifTrue:[ |
|
1789 |
boldFont isNil ifTrue:[ |
|
899
fe2b44d0d9c1
moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1790 |
boldFont := savedFont asBold onDevice:device |
307 | 1791 |
]. |
1792 |
f := boldFont. |
|
1793 |
] ifFalse:[ |
|
1794 |
italic ifTrue:[ |
|
1795 |
italicFont isNil ifTrue:[ |
|
899
fe2b44d0d9c1
moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1796 |
italicFont := savedFont asItalic onDevice:device |
307 | 1797 |
]. |
1798 |
f := italicFont |
|
1799 |
] ifFalse:[ |
|
1800 |
f := savedFont |
|
1801 |
] |
|
1802 |
]. |
|
899
fe2b44d0d9c1
moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1803 |
f := f onDevice:device. |
2233
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1804 |
"/ disabled - it is too ugly (and not handled correctly, anyway). |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1805 |
"/ wasItalic ~~ italic ifTrue:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1806 |
"/ italic ifFalse:[ |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1807 |
"/ "/ going from italic to non-italic; leave some space for the shear |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1808 |
"/ l := l + (f width " // 2" ) |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1809 |
"/ ]. |
04205abedbff
space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents:
2181
diff
changeset
|
1810 |
"/ ]. |
307 | 1811 |
l := l + (f widthOf:string from:pos to:(pos + len - 1)). |
1812 |
pos := pos + len |
|
1813 |
]. |
|
1814 |
||
1815 |
^ l |
|
1816 |
||
404
14cf34141532
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
1817 |
"Modified: 5.7.1996 / 17:54:58 / cg" |
307 | 1818 |
! ! |
1819 |
||
1820 |
!Text methodsFor:'replacing'! |
|
1821 |
||
1822 |
replaceFrom:start to:stop with:aCollection startingAt:startIndex |
|
343 | 1823 |
"replace a range of characters, from another string or text object. |
607 | 1824 |
The corresponding characters' emphasis information is also copied. |
1825 |
Return the receiver." |
|
343 | 1826 |
|
2181
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1827 |
|idx maxCharacter| |
1402
2fe462e2fe8e
care for text with twobyte strings
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
1828 |
|
307 | 1829 |
aCollection isString ifTrue:[ |
2181
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1830 |
aCollection bitsPerCharacter > string bitsPerCharacter ifTrue:[ |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1831 |
"have to create a new string with appropriate character size" |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1832 |
string := aCollection string species fromString:string. |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1833 |
]. |
307 | 1834 |
aCollection hasChangeOfEmphasis ifTrue:[ |
1835 |
string replaceFrom:start to:stop with:aCollection startingAt:startIndex. |
|
1836 |
idx := startIndex. |
|
1837 |
start to:stop do:[:col | |
|
1838 |
self emphasisAt:col put:(aCollection emphasisAt:idx). |
|
1839 |
idx := idx + 1. |
|
1840 |
]. |
|
1841 |
^ self. |
|
1842 |
] |
|
2181
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1843 |
] ifFalse:[ |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1844 |
"aCollection is an arbitrary SequenceableCollection" |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1845 |
maxCharacter := $0. "some 8-bit character" |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1846 |
aCollection do:[:eachCharacter | |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1847 |
maxCharacter := maxCharacter max:eachCharacter |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1848 |
]. |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1849 |
maxCharacter bitsPerCharacter > string bitsPerCharacter ifTrue:[ |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1850 |
"have to create a new string with appropriate character size" |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1851 |
string := maxCharacter stringSpecies fromString:string. |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1852 |
]. |
307 | 1853 |
]. |
2181
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1854 |
|
307 | 1855 |
string replaceFrom:start to:stop with:aCollection startingAt:startIndex. |
1856 |
self emphasizeFrom:start to:stop with:nil |
|
1857 |
||
1858 |
" |
|
1859 |
((Text string:'hello') allBold emphasisAt:2 put:#italic) |
|
2181
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1860 |
replaceFrom:1 to:3 with:'HEL' startingAt:1 |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1861 |
|
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1862 |
((Text string:'hello') allBold emphasisAt:2 put:#italic) |
86122f38fc09
Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents:
2128
diff
changeset
|
1863 |
replaceFrom:1 to:3 with:#($H $E $L) startingAt:1 |
307 | 1864 |
" |
1865 |
||
607 | 1866 |
"Modified: / 28.1.1998 / 16:50:06 / cg" |
304 | 1867 |
! ! |
1868 |
||
454
ffc79ebcbb20
oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents:
450
diff
changeset
|
1869 |
!Text class methodsFor:'documentation'! |
304 | 1870 |
|
1871 |
version |
|
3472 | 1872 |
^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.128 2015-01-29 17:54:22 cg Exp $' |
2305
2108d674c8b2
comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1873 |
! |
2108d674c8b2
comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1874 |
|
2108d674c8b2
comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1875 |
version_CVS |
3472 | 1876 |
^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.128 2015-01-29 17:54:22 cg Exp $' |
304 | 1877 |
! ! |
1160 | 1878 |
|
2867 | 1879 |
|
314 | 1880 |
Text initialize! |