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