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