author | Claus Gittinger <cg@exept.de> |
Thu, 14 May 1998 19:24:30 +0200 | |
changeset 710 | fc74f135494d |
parent 689 | 42a774852fed |
child 788 | 5307f69829c6 |
permissions | -rw-r--r-- |
662 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
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 |
" |
|
12 |
||
13 |
||
14 |
||
15 |
Parser subclass:#SyntaxHighlighter |
|
16 |
instanceVariableNames:'sourceText identifierColor identifierEmphasis |
|
17 |
argumentIdentifierColor argumentIdentifierEmphasis |
|
18 |
localIdentifierColor localIdentifierEmphasis |
|
665 | 19 |
unknownIdentifierColor unknownIdentifierEmphasis |
662 | 20 |
globalIdentifierColor globalIdentifierEmphasis commentColor |
21 |
commentEmphasis methodSelectorEmphasis methodSelectorColor |
|
22 |
selectorEmphasis selectorColor stringColor stringEmphasis |
|
672 | 23 |
symbolColor symbolEmphasis selfColor selfEmphasis superColor |
24 |
superEmphasis hereColor hereEmphasis thisContextColor |
|
25 |
thisContextEmphasis booleanConstantColor booleanConstantEmphasis |
|
686 | 26 |
constantColor constantEmphasis bracketColor bracketEmphasis |
27 |
instVarIdentifierColor instVarIdentifierEmphasis' |
|
662 | 28 |
classVariableNames:'' |
29 |
poolDictionaries:'' |
|
30 |
category:'System-Compiler' |
|
31 |
! |
|
32 |
||
33 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
34 |
||
35 |
copyright |
|
36 |
" |
|
37 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
38 |
All Rights Reserved |
|
39 |
||
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
||
48 |
||
681 | 49 |
! |
50 |
||
51 |
documentation |
|
52 |
" |
|
53 |
colors a method. |
|
54 |
" |
|
55 |
||
56 |
||
662 | 57 |
! ! |
58 |
||
59 |
!SyntaxHighlighter class methodsFor:'highlighting'! |
|
60 |
||
684
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
61 |
formatExpression:aString in:aClass |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
62 |
"format (recolor) an expression in a given class. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
63 |
Return the text containing font changes and color information." |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
64 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
65 |
|parser tree text endPos| |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
66 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
67 |
aString isNil ifTrue:[^ nil]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
68 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
69 |
parser := self for:(ReadStream on:aString string) in:aClass. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
70 |
parser ignoreErrors. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
71 |
parser ignoreWarnings. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
72 |
parser sourceText:(text := aString string asText). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
73 |
"/ use an array here - this can be changed much faster using #at:put: |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
74 |
text emphasisCollection:(Array new:aString size). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
75 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
76 |
parser nextToken. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
77 |
tree := parser expression. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
78 |
"/ now, convert the emphasis-array to a runArray |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
79 |
text emphasisCollection:(text emphasis asRunArray). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
80 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
81 |
tree == #Error ifTrue:[ |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
82 |
"/ mhmh - which is better ... |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
83 |
"/ alternative1: color rest after error in red |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
84 |
"/ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
85 |
"/ emphasizeFrom:(parser sourceStream position) |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
86 |
"/ to:text size |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
87 |
"/ with:(#color->Color red). |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
88 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
89 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
90 |
"/ alternative2: take original emphasis for rest |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
91 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
92 |
endPos := parser sourceStream position. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
93 |
endPos >= text size ifTrue:[ |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
94 |
^ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
95 |
]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
96 |
^ (text copyTo:endPos) , (aString copyFrom:(endPos+1)) |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
97 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
98 |
"/ alternative3: no emphasis for rest. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
99 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
100 |
"/ ^ text "/ aString |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
101 |
]. |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
102 |
^ text |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
103 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
104 |
" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
105 |
self |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
106 |
formatExpression:'(1 + 2) max:5' |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
107 |
in:UndefinedObject |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
108 |
" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
109 |
|
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
110 |
"Modified: / 7.4.1998 / 09:57:19 / cg" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
111 |
"Created: / 9.4.1998 / 16:57:16 / cg" |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
112 |
! |
dd691ac07f90
added entry to color an expression
Claus Gittinger <cg@exept.de>
parents:
681
diff
changeset
|
113 |
|
662 | 114 |
formatMethod:aString in:aClass |
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
115 |
"format (recolor) a method in a given class. |
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
116 |
Return the text containing font changes and color information." |
662 | 117 |
|
678 | 118 |
|parser tree text endPos| |
662 | 119 |
|
120 |
aString isNil ifTrue:[^ nil]. |
|
121 |
||
689 | 122 |
Object errorSignal handle:[:ex | |
123 |
^ aString |
|
124 |
] do:[ |
|
125 |
parser := self for:(ReadStream on:aString string) in:aClass. |
|
126 |
parser ignoreErrors. |
|
127 |
parser ignoreWarnings. |
|
128 |
parser sourceText:(text := aString string asText). |
|
129 |
"/ use an array here - this can be changed much faster using #at:put: |
|
130 |
text emphasisCollection:(Array new:aString size). |
|
662 | 131 |
|
689 | 132 |
tree := parser parseMethod. |
133 |
"/ now, convert the emphasis-array to a runArray |
|
134 |
text emphasisCollection:(text emphasis asRunArray). |
|
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
135 |
|
689 | 136 |
tree == #Error ifTrue:[ |
137 |
"/ mhmh - which is better ... |
|
138 |
"/ alternative1: color rest after error in red |
|
139 |
"/ text |
|
140 |
"/ emphasizeFrom:(parser sourceStream position) |
|
141 |
"/ to:text size |
|
142 |
"/ with:(#color->Color red). |
|
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
143 |
|
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
144 |
|
689 | 145 |
"/ alternative2: take original emphasis for rest |
680
ebc432c71aec
much faster (due to runArray changes.
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
146 |
|
689 | 147 |
endPos := parser sourceStream position. |
148 |
endPos >= text size ifTrue:[ |
|
149 |
^ text |
|
150 |
]. |
|
151 |
^ (text copyTo:endPos) , (aString copyFrom:(endPos+1)) |
|
152 |
||
153 |
"/ alternative3: no emphasis for rest. |
|
154 |
||
155 |
"/ ^ text "/ aString |
|
678 | 156 |
]. |
689 | 157 |
^ text |
158 |
] |
|
662 | 159 |
" |
160 |
self |
|
161 |
formatMethod:'foo |
|
162 |
^ self bar:''hello''. |
|
163 |
||
164 |
' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , ' |
|
165 |
' |
|
166 |
in:UndefinedObject |
|
167 |
" |
|
168 |
||
689 | 169 |
"Modified: / 16.4.1998 / 23:29:43 / cg" |
662 | 170 |
! ! |
171 |
||
172 |
!SyntaxHighlighter methodsFor:'accessing'! |
|
173 |
||
174 |
sourceText |
|
175 |
"return the value of the instance variable 'sourceText' (automatically generated)" |
|
176 |
||
177 |
^ sourceText |
|
178 |
||
179 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
180 |
! |
|
181 |
||
182 |
sourceText:something |
|
183 |
"set the value of the instance variable 'sourceText' (automatically generated)" |
|
184 |
||
185 |
sourceText := something. |
|
186 |
||
187 |
"Created: / 31.3.1998 / 11:49:05 / cg" |
|
188 |
! ! |
|
189 |
||
190 |
!SyntaxHighlighter methodsFor:'initialization'! |
|
191 |
||
192 |
initialize |
|
193 |
|prefs| |
|
194 |
||
195 |
super initialize. |
|
196 |
||
197 |
prefs := UserPreferences current. |
|
198 |
identifierEmphasis := prefs identifierEmphasis. |
|
199 |
identifierColor := prefs identifierColor. |
|
200 |
argumentIdentifierEmphasis := prefs argumentIdentifierEmphasis. |
|
201 |
argumentIdentifierColor := prefs argumentIdentifierColor. |
|
202 |
localIdentifierEmphasis := prefs localIdentifierEmphasis. |
|
203 |
localIdentifierColor := prefs localIdentifierColor. |
|
686 | 204 |
instVarIdentifierEmphasis := prefs instVarIdentifierEmphasis. |
205 |
instVarIdentifierColor := prefs instVarIdentifierColor. |
|
662 | 206 |
globalIdentifierEmphasis := prefs globalIdentifierEmphasis. |
207 |
globalIdentifierColor := prefs globalIdentifierColor. |
|
665 | 208 |
unknownIdentifierEmphasis := prefs unknownIdentifierEmphasis. |
209 |
unknownIdentifierColor := prefs unknownIdentifierColor. |
|
662 | 210 |
commentEmphasis := prefs commentEmphasis. |
211 |
commentColor := prefs commentColor. |
|
212 |
methodSelectorEmphasis := prefs methodSelectorEmphasis. |
|
213 |
methodSelectorColor := prefs methodSelectorColor. |
|
214 |
selectorEmphasis := prefs selectorEmphasis. |
|
215 |
selectorColor := prefs selectorColor. |
|
216 |
stringEmphasis := prefs stringEmphasis. |
|
217 |
stringColor := prefs stringColor. |
|
672 | 218 |
symbolEmphasis := prefs symbolEmphasis. |
219 |
symbolColor := prefs symbolColor. |
|
662 | 220 |
selfEmphasis := prefs selfEmphasis. |
221 |
selfColor := prefs selfColor. |
|
222 |
hereEmphasis := prefs hereEmphasis. |
|
223 |
hereColor := prefs hereColor. |
|
224 |
superEmphasis := prefs superEmphasis. |
|
225 |
superColor := prefs superColor. |
|
226 |
thisContextEmphasis := prefs thisContextEmphasis. |
|
227 |
thisContextColor := prefs thisContextColor. |
|
228 |
constantEmphasis := prefs constantEmphasis. |
|
229 |
constantColor := prefs constantColor. |
|
230 |
booleanConstantEmphasis := prefs booleanConstantEmphasis. |
|
231 |
booleanConstantColor := prefs booleanConstantColor. |
|
673 | 232 |
bracketEmphasis := prefs bracketEmphasis. |
233 |
bracketColor := prefs bracketColor. |
|
662 | 234 |
|
235 |
"Created: / 31.3.1998 / 15:12:55 / cg" |
|
686 | 236 |
"Modified: / 16.4.1998 / 18:40:19 / cg" |
662 | 237 |
! ! |
238 |
||
239 |
!SyntaxHighlighter methodsFor:'syntax detection'! |
|
240 |
||
241 |
markArgumentIdentifierFrom:pos1 to:pos2 |
|
242 |
self |
|
243 |
markFrom:pos1 to:pos2 |
|
244 |
withEmphasis:argumentIdentifierEmphasis color:argumentIdentifierColor |
|
245 |
||
246 |
"Modified: / 31.3.1998 / 18:01:27 / cg" |
|
247 |
! |
|
248 |
||
249 |
markBooleanConstantFrom:pos1 to:pos2 |
|
250 |
self |
|
251 |
markFrom:pos1 to:pos2 |
|
665 | 252 |
withEmphasis:booleanConstantEmphasis color:booleanConstantColor |
662 | 253 |
|
254 |
"Created: / 31.3.1998 / 18:09:01 / cg" |
|
665 | 255 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
662 | 256 |
! |
257 |
||
673 | 258 |
markBracketAt:pos |
259 |
self |
|
260 |
markFrom:pos to:pos |
|
261 |
withEmphasis:bracketEmphasis color:bracketColor |
|
262 |
||
263 |
"Created: / 31.3.1998 / 18:09:01 / cg" |
|
264 |
"Modified: / 31.3.1998 / 19:36:44 / cg" |
|
265 |
! |
|
266 |
||
662 | 267 |
markCommentFrom:pos1 to:pos2 |
268 |
self |
|
269 |
markFrom:pos1 to:pos2 |
|
270 |
withEmphasis:commentEmphasis color:commentColor |
|
271 |
||
272 |
"Modified: / 31.3.1998 / 18:01:55 / cg" |
|
273 |
! |
|
274 |
||
275 |
markConstantFrom:pos1 to:pos2 |
|
276 |
self |
|
277 |
markFrom:pos1 to:pos2 |
|
278 |
withEmphasis:constantEmphasis color:constantColor |
|
279 |
||
280 |
"Modified: / 31.3.1998 / 18:01:44 / cg" |
|
281 |
"Created: / 31.3.1998 / 18:09:22 / cg" |
|
282 |
! |
|
283 |
||
284 |
markFrom:pos1 to:pos2 withEmphasis:fontEmp color:clr |
|
285 |
|e| |
|
286 |
||
669 | 287 |
clr = Color black ifTrue:[ |
288 |
e := fontEmp |
|
289 |
] ifFalse:[ |
|
290 |
e := Text addEmphasis:fontEmp to:(#color->clr). |
|
291 |
]. |
|
662 | 292 |
sourceText emphasizeFrom:pos1 to:pos2 with:e |
293 |
||
294 |
"Created: / 31.3.1998 / 13:26:53 / cg" |
|
669 | 295 |
"Modified: / 1.4.1998 / 12:51:56 / cg" |
662 | 296 |
! |
297 |
||
298 |
markGlobalIdentifierFrom:pos1 to:pos2 |
|
299 |
self |
|
300 |
markFrom:pos1 to:pos2 |
|
301 |
withEmphasis:globalIdentifierEmphasis color:globalIdentifierColor |
|
302 |
||
303 |
"Modified: / 31.3.1998 / 18:02:14 / cg" |
|
304 |
! |
|
305 |
||
306 |
markHereFrom:pos1 to:pos2 |
|
307 |
self |
|
308 |
markFrom:pos1 to:pos2 |
|
309 |
withEmphasis:hereEmphasis color:hereColor |
|
310 |
||
311 |
"Modified: / 31.3.1998 / 18:02:25 / cg" |
|
312 |
! |
|
313 |
||
314 |
markIdentifierFrom:pos1 to:pos2 |
|
315 |
self |
|
316 |
markFrom:pos1 to:pos2 |
|
317 |
withEmphasis:identifierEmphasis color:identifierColor |
|
318 |
||
319 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
320 |
"Created: / 31.3.1998 / 18:04:56 / cg" |
|
321 |
! |
|
322 |
||
686 | 323 |
markInstVarIdentifierFrom:pos1 to:pos2 |
324 |
self |
|
325 |
markFrom:pos1 to:pos2 |
|
326 |
withEmphasis:instVarIdentifierEmphasis color:instVarIdentifierColor |
|
327 |
||
328 |
"Created: / 16.4.1998 / 18:35:40 / cg" |
|
329 |
"Modified: / 16.4.1998 / 18:37:30 / cg" |
|
330 |
! |
|
331 |
||
662 | 332 |
markLocalIdentifierFrom:pos1 to:pos2 |
333 |
self |
|
334 |
markFrom:pos1 to:pos2 |
|
335 |
withEmphasis:localIdentifierEmphasis color:localIdentifierColor |
|
336 |
||
337 |
"Modified: / 31.3.1998 / 18:02:39 / cg" |
|
338 |
! |
|
339 |
||
340 |
markMethodSelectorFrom:pos1 to:pos2 |
|
341 |
self |
|
342 |
markFrom:pos1 to:pos2 |
|
343 |
withEmphasis:methodSelectorEmphasis color:methodSelectorColor |
|
344 |
||
345 |
"Modified: / 31.3.1998 / 18:02:52 / cg" |
|
346 |
! |
|
347 |
||
348 |
markSelectorFrom:pos1 to:pos2 |
|
672 | 349 |
|
350 |
"/ uncommenting the code below |
|
351 |
"/ will suppress highlighting of common selectors ... |
|
352 |
"/ |
|
353 |
"/ (#( |
|
354 |
"/ 'ifTrue:' |
|
355 |
"/ 'ifFalse:' |
|
356 |
"/ 'not' |
|
357 |
"/ 'and:' |
|
358 |
"/ 'or:' |
|
359 |
"/ '=' |
|
360 |
"/ '==' |
|
361 |
"/ '~=' |
|
362 |
"/ '~~' |
|
363 |
"/ ) includes:tokenName) ifTrue:[ |
|
364 |
"/ ^ self |
|
365 |
"/ ]. |
|
366 |
||
662 | 367 |
self |
368 |
markFrom:pos1 to:pos2 |
|
369 |
withEmphasis:selectorEmphasis color:selectorColor |
|
370 |
||
672 | 371 |
"Modified: / 1.4.1998 / 13:14:43 / cg" |
662 | 372 |
! |
373 |
||
374 |
markSelfFrom:pos1 to:pos2 |
|
375 |
self |
|
376 |
markFrom:pos1 to:pos2 |
|
377 |
withEmphasis:selfEmphasis color:selfColor |
|
378 |
||
379 |
"Modified: / 31.3.1998 / 18:03:10 / cg" |
|
380 |
! |
|
381 |
||
382 |
markStringFrom:pos1 to:pos2 |
|
383 |
self |
|
384 |
markFrom:pos1 to:pos2 |
|
385 |
withEmphasis:stringEmphasis color:stringColor |
|
386 |
||
387 |
"Modified: / 31.3.1998 / 18:03:18 / cg" |
|
388 |
! |
|
389 |
||
390 |
markSuperFrom:pos1 to:pos2 |
|
391 |
self |
|
392 |
markFrom:pos1 to:pos2 |
|
393 |
withEmphasis:superEmphasis color:superColor |
|
394 |
||
395 |
"Modified: / 31.3.1998 / 18:03:26 / cg" |
|
396 |
! |
|
397 |
||
672 | 398 |
markSymbolFrom:pos1 to:pos2 |
399 |
self |
|
400 |
markFrom:pos1 to:pos2 |
|
401 |
withEmphasis:symbolEmphasis color:symbolColor |
|
402 |
||
403 |
"Created: / 1.4.1998 / 12:56:47 / cg" |
|
404 |
"Modified: / 1.4.1998 / 12:58:00 / cg" |
|
405 |
! |
|
406 |
||
662 | 407 |
markThisContextFrom:pos1 to:pos2 |
408 |
self |
|
409 |
markFrom:pos1 to:pos2 |
|
410 |
withEmphasis:thisContextEmphasis color:thisContextColor |
|
411 |
||
412 |
"Modified: / 31.3.1998 / 18:03:36 / cg" |
|
665 | 413 |
! |
414 |
||
415 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
416 |
self |
|
417 |
markFrom:pos1 to:pos2 |
|
418 |
withEmphasis:unknownIdentifierEmphasis color:unknownIdentifierColor |
|
419 |
||
420 |
"Created: / 31.3.1998 / 19:09:26 / cg" |
|
421 |
"Modified: / 31.3.1998 / 19:10:30 / cg" |
|
686 | 422 |
! |
423 |
||
424 |
markVariable:v |
|
425 |
"support for syntaxColoring" |
|
426 |
||
427 |
|pos endPos| |
|
428 |
||
429 |
pos := tokenPosition. |
|
430 |
endPos := pos+tokenName size-1. |
|
431 |
self markVariable:v from:pos to:endPos |
|
432 |
||
433 |
"Modified: / 16.4.1998 / 18:49:51 / cg" |
|
434 |
! |
|
435 |
||
436 |
markVariable:v from:pos to:endPos |
|
437 |
"support for syntaxColoring" |
|
438 |
||
439 |
|type| |
|
440 |
||
441 |
type := v type. |
|
442 |
(type == #BlockArg |
|
443 |
or:[type == #MethodArg]) ifTrue:[ |
|
444 |
self markArgumentIdentifierFrom:pos to:endPos. |
|
445 |
^ self |
|
446 |
]. |
|
447 |
(type == #BlockVariable |
|
448 |
or:[type == #MethodVariable]) ifTrue:[ |
|
449 |
self markLocalIdentifierFrom:pos to:endPos. |
|
450 |
^ self |
|
451 |
]. |
|
452 |
(type == #GlobalVariable) ifTrue:[ |
|
453 |
self markGlobalIdentifierFrom:pos to:endPos. |
|
454 |
^ self |
|
455 |
]. |
|
456 |
(type == #InstanceVariable) ifTrue:[ |
|
457 |
self markInstVarIdentifierFrom:pos to:endPos. |
|
458 |
^ self |
|
459 |
]. |
|
460 |
||
461 |
self markIdentifierFrom:pos to:endPos. |
|
462 |
||
463 |
"Created: / 16.4.1998 / 18:49:34 / cg" |
|
464 |
"Modified: / 16.4.1998 / 18:58:10 / cg" |
|
662 | 465 |
! ! |
466 |
||
467 |
!SyntaxHighlighter class methodsFor:'documentation'! |
|
468 |
||
469 |
version |
|
689 | 470 |
^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.13 1998-04-17 18:58:20 cg Exp $' |
662 | 471 |
! ! |