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