author | Claus Gittinger <cg@exept.de> |
Sun, 21 Aug 2011 16:49:30 +0200 | |
changeset 10644 | 02846c439aa8 |
parent 10634 | 9db32390ac37 |
child 10650 | fccac41fd387 |
permissions | -rw-r--r-- |
9980 | 1 |
" |
10077 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
3 |
All Rights Reserved |
9980 | 4 |
|
10077 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9980 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
CodeViewService subclass:#CodeHighlightingService |
|
10439
6a41520db1be
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10438
diff
changeset
|
31 |
instanceVariableNames:'job done' |
6a41520db1be
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10438
diff
changeset
|
32 |
classVariableNames:'' |
6a41520db1be
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10438
diff
changeset
|
33 |
poolDictionaries:'' |
6a41520db1be
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10438
diff
changeset
|
34 |
category:'Interface-CodeView' |
9980 | 35 |
! |
36 |
||
37 |
!CodeHighlightingService class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
10077 | 41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
42 |
All Rights Reserved |
10077 | 43 |
|
44 |
Permission is hereby granted, free of charge, to any person |
|
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
9980 | 52 |
|
10077 | 53 |
The above copyright notice and this permission notice shall be |
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9980 | 64 |
" |
65 |
! ! |
|
66 |
||
67 |
!CodeHighlightingService class methodsFor:'accessing'! |
|
68 |
||
69 |
label |
|
70 |
||
71 |
"Answers short label - for UI" |
|
72 |
||
73 |
^'Syntax Highlighting' |
|
74 |
||
75 |
"Created: / 07-03-2010 / 14:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 |
! ! |
|
77 |
||
10486 | 78 |
!CodeHighlightingService methodsFor:'accessing'! |
79 |
||
80 |
syntaxHighlighter |
|
81 |
| app lang highlighter mthd class | |
|
82 |
||
83 |
"First, ask application..." |
|
84 |
app := codeView application. |
|
85 |
mthd := codeView methodHolder value. |
|
86 |
class := codeView classHolder value. |
|
87 |
app notNil ifTrue:[ |
|
88 |
(mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[ |
|
89 |
highlighter := app syntaxHighlighterForMethod:mthd. |
|
90 |
] ifFalse:[ |
|
91 |
(class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[ |
|
92 |
highlighter := app syntaxHighlighterForClass: class. |
|
93 |
]. |
|
94 |
] |
|
95 |
]. |
|
96 |
"App did not provide any highlighter..." |
|
97 |
highlighter isNil ifTrue:[ |
|
98 |
highlighter := (lang := codeView languageHolder value) |
|
99 |
ifNil:[nil] |
|
100 |
ifNotNil:[lang syntaxHighlighterClass]. |
|
101 |
]. |
|
102 |
"HACK!!!!!!" |
|
103 |
highlighter == SyntaxHighlighter ifTrue:[ |
|
104 |
highlighter := SyntaxHighlighter2 |
|
105 |
]. |
|
106 |
^ highlighter |
|
107 |
||
108 |
"Modified: / 05-07-2011 / 11:10:11 / cg" |
|
109 |
"Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
110 |
! |
|
111 |
||
112 |
syntaxHighlighters |
|
113 |
||
114 |
| highlighters | |
|
115 |
||
116 |
highlighters := OrderedCollection new: 4. |
|
117 |
||
118 |
codeView services do:[:service| |
|
119 |
| highlighter | |
|
120 |
highlighter := service syntaxHighlighter. |
|
121 |
highlighter notNil ifTrue:[ |
|
122 |
"HACK, since AbstractSyntaxHighlighter overwrite |
|
123 |
emphasis instead of adding it..." |
|
124 |
(highlighter isKindOf: AbstractSyntaxHighlighter class) ifTrue:[ |
|
125 |
highlighters addFirst: highlighter |
|
126 |
] ifFalse:[ |
|
127 |
highlighters add: highlighter |
|
128 |
]. |
|
129 |
] |
|
130 |
]. |
|
131 |
||
132 |
^highlighters |
|
133 |
||
134 |
"Created: / 05-08-2011 / 10:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
! ! |
|
136 |
||
9980 | 137 |
!CodeHighlightingService methodsFor:'change & update'! |
138 |
||
139 |
update: aspect with: param from: sender |
|
140 |
||
10149 | 141 |
sender == textView modifiedChannel ifTrue:[^self codeChanged: false]. |
142 |
sender == textView model ifTrue:[^self codeChanged: true]. |
|
9980 | 143 |
sender == codeView languageHolder ifTrue:[^self codeChanged: true]. |
144 |
sender == codeView classHolder ifTrue:[^self codeChanged: true]. |
|
145 |
||
146 |
super update: aspect with: param from: sender |
|
147 |
||
148 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10149 | 149 |
"Modified: / 05-07-2011 / 10:18:08 / cg" |
9980 | 150 |
! ! |
151 |
||
10420 | 152 |
!CodeHighlightingService methodsFor:'initialization'! |
153 |
||
154 |
initialize |
|
155 |
||
10486 | 156 |
job := (Smalltalk at:#BackgroundJob) |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
157 |
named: 'Syntax Highlighting Job' |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
158 |
on:[self syntaxHighlight: true]. |
10420 | 159 |
|
160 |
"Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10439
6a41520db1be
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10438
diff
changeset
|
161 |
"Modified: / 03-08-2011 / 16:47:53 / cg" |
10420 | 162 |
! ! |
163 |
||
9980 | 164 |
!CodeHighlightingService methodsFor:'private'! |
165 |
||
166 |
codeChanged: force |
|
167 |
||
168 |
(force or:[codeView textView modified]) ifTrue: |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
169 |
[self syntaxHighlight]. |
9980 | 170 |
|
10420 | 171 |
"Modified: / 29-07-2011 / 11:07:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9980 | 172 |
! |
173 |
||
174 |
setHighlightedCode:newCode elements: elements |
|
175 |
"the background synhighlighter has generated new colored text, |
|
176 |
with highlighted syntax. |
|
177 |
If there have been no modifications in the meantime, install it." |
|
178 |
||
10420 | 179 |
|firstShown lastShown cursorWasOn anyChange newLines l replaceAction list| |
9980 | 180 |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
181 |
textView modified ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
182 |
"/ new input arrived in the meantime |
10420 | 183 |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
184 |
^ self |
9980 | 185 |
]. |
10420 | 186 |
done ifFalse:[ |
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
187 |
"/ another coloring process has already been started. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
188 |
"/ ignore this (leftover) code. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
189 |
^ self |
9980 | 190 |
]. |
191 |
firstShown := textView firstLineShown. |
|
192 |
lastShown := textView lastLineShown. |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
193 |
|
9980 | 194 |
replaceAction := [:lNr :line | |
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
195 |
|oldLine| |
9980 | 196 |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
197 |
oldLine := list at:lNr ifAbsent:nil. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
198 |
oldLine notNil ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
199 |
line notNil ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
200 |
"/ this check is needed - there is a race |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
201 |
"/ when the text is converted. This detects the |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
202 |
"/ resulting error. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
203 |
"/ Certainly a kludge. |
9980 | 204 |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
205 |
oldLine string = line string ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
206 |
oldLine emphasis ~= line emphasis ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
207 |
textView modifiedChannel removeDependent:self. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
208 |
list at:lNr put:line. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
209 |
textView modifiedChannel addDependent:self. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
210 |
(lNr between:firstShown and:lastShown) ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
211 |
anyChange ifFalse:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
212 |
anyChange := true. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
213 |
cursorWasOn := textView hideCursor |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
214 |
]. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
215 |
textView redrawLine:lNr |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
216 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
217 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
218 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
219 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
220 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
221 |
]. |
10234
7cdbded1e728
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10151
diff
changeset
|
222 |
|
9980 | 223 |
anyChange := false. |
224 |
newLines := newCode asStringCollection. |
|
225 |
list := textView list. |
|
226 |
list isNil ifTrue:[ |
|
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
227 |
textView list:newLines. |
9980 | 228 |
] ifFalse:[ |
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
229 |
"/ the cursor line first - that's where your eyes are ... |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
230 |
(l := textView cursorLine) notNil ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
231 |
l <= newLines size ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
232 |
replaceAction value:l value:(newLines at:l) |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
233 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
234 |
]. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
235 |
newLines keysAndValuesDo:replaceAction. |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
236 |
anyChange ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
237 |
cursorWasOn ifTrue:[ |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
238 |
textView showCursor |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
239 |
] |
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
240 |
] |
9980 | 241 |
]. |
242 |
codeView syntaxElements: elements |
|
243 |
||
244 |
"Modified: / 09-10-2006 / 11:50:17 / cg" |
|
245 |
"Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10420 | 246 |
"Modified: / 29-07-2011 / 11:10:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10634
9db32390ac37
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10497
diff
changeset
|
247 |
"Modified (format): / 21-08-2011 / 09:38:22 / cg" |
9980 | 248 |
! |
249 |
||
250 |
showInfo: aString |
|
251 |
||
252 |
codeView showInfo: aString |
|
253 |
||
254 |
"Created: / 06-03-2010 / 19:34:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
255 |
! |
|
256 |
||
10420 | 257 |
syntaxHighlight |
9980 | 258 |
|
10486 | 259 |
|highlighters prio | |
9980 | 260 |
|
10644 | 261 |
^ self. |
10486 | 262 |
highlighters := self syntaxHighlighters. |
9980 | 263 |
|
10486 | 264 |
highlighters isEmptyOrNil ifTrue:[ |
265 |
"No higlighter, nothing to do" |
|
266 |
^self |
|
10420 | 267 |
]. |
9980 | 268 |
|
269 |
"/ this clobbers the codeViews modified state; therefore, we have to remember |
|
270 |
"/ this info somewhere ... |
|
10244 | 271 |
codeView browser ifNotNil:[ |
10486 | 272 |
textView modified ifTrue:[ |
273 |
codeView browser navigationState realModifiedState: true |
|
274 |
]. |
|
275 |
textView modifiedChannel setValue:false. |
|
9980 | 276 |
]. |
277 |
||
10420 | 278 |
job scheduled ifTrue:[ |
10486 | 279 |
job running ifFalse:[ |
280 |
"/ process already created, but did not get a change to start yet; |
|
281 |
^ self |
|
282 |
] ifTrue:[ |
|
283 |
job stop. |
|
284 |
] |
|
9980 | 285 |
]. |
286 |
prio := Processor userBackgroundPriority - 1. |
|
287 |
textView shown ifFalse:[ |
|
10486 | 288 |
prio := prio - 1 max:1 |
9980 | 289 |
]. |
10149 | 290 |
|
10420 | 291 |
job startWithPriority: prio. |
292 |
||
293 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
294 |
"Created: / 29-07-2011 / 11:07:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10644 | 295 |
"Modified: / 21-08-2011 / 15:54:42 / cg" |
10420 | 296 |
! |
297 |
||
298 |
syntaxHighlight: delayed |
|
299 |
||
10486 | 300 |
|oldCode oldCodeList newCode elements cls mthd highlighterClasses| |
10420 | 301 |
|
302 |
done := false. |
|
303 |
codeView syntaxElements: nil. |
|
304 |
codeView syntaxElementSelection: nil. |
|
305 |
||
10486 | 306 |
highlighterClasses := self syntaxHighlighters. |
10149 | 307 |
|
10420 | 308 |
cls := codeView klass. |
309 |
(cls notNil and:[cls isObsolete]) ifTrue:[ |
|
10486 | 310 |
cls isMeta ifTrue:[ |
311 |
cls := (Smalltalk at:cls theNonMetaclass name) class |
|
312 |
] ifFalse:[ |
|
313 |
cls := Smalltalk at:cls name |
|
314 |
]. |
|
10420 | 315 |
]. |
316 |
mthd := codeView methodHolder value. |
|
10149 | 317 |
|
10420 | 318 |
textView modified ifFalse:[ |
10486 | 319 |
oldCodeList := textView list copy. |
320 |
textView modified ifFalse:[ |
|
321 |
oldCodeList isNil ifFalse:[ |
|
322 |
oldCode := oldCodeList asStringWithoutEmphasis. |
|
323 |
textView modified ifFalse:[ |
|
324 |
Screen currentScreenQuerySignal answer:codeView device |
|
325 |
do:[ |
|
326 |
Parser::ParseError handle:[:ex | |
|
327 |
|errMsg| |
|
9980 | 328 |
|
10486 | 329 |
errMsg := ex description asStringCollection first asString. |
9980 | 330 |
|
10486 | 331 |
"/ Transcript topView raiseDeiconified. |
332 |
"/ Transcript showCR:'ParseError: ', ex description. |
|
9980 | 333 |
"/ self halt. |
10486 | 334 |
"/ self showInfo:(errMsg colorizeAllWith:Color red). |
335 |
newCode := nil. |
|
336 |
] do:[ |
|
337 |
elements := SortedCollection new. |
|
338 |
newCode := oldCode asText. |
|
339 |
codeView codeAspect == #method ifTrue:[ |
|
340 |
highlighterClasses do:[:e|newCode := e formatMethod:mthd source:newCode in:cls using: nil elementsInto: elements]. |
|
341 |
] ifFalse:[ |
|
342 |
codeView codeAspect == #expression ifTrue:[ |
|
343 |
highlighterClasses do:[:e|newCode := e formatExpression:newCode in:cls elementsInto: elements]. |
|
344 |
] ifFalse:[ |
|
345 |
codeView codeAspect == #classDefinition ifTrue:[ |
|
346 |
highlighterClasses do:[:e|newCode := e formatClassDefinition:newCode in:cls elementsInto: elements]. |
|
347 |
] |
|
348 |
]. |
|
349 |
]. |
|
350 |
] |
|
351 |
]. |
|
352 |
newCode notNil ifTrue:[ |
|
353 |
textView modified ifFalse:[ |
|
354 |
newCode ~= oldCodeList ifTrue:[ |
|
355 |
newCode := newCode asStringCollection. |
|
356 |
textView modified ifFalse:[ |
|
357 |
done := true. |
|
358 |
textView notNil ifTrue:[ |
|
359 |
"/ must add this event - and not been interrupted |
|
360 |
"/ by any arriving key-event. |
|
361 |
"/ self showInfo:nil. |
|
362 |
delayed ifTrue:[ |
|
363 |
codeView sensor |
|
364 |
pushUserEvent:#setHighlightedCode:elements: |
|
365 |
for:self |
|
366 |
withArguments:(Array with:newCode with: elements). |
|
367 |
"/self delayedUpdateBufferLabelWithCheckIfModified |
|
368 |
] ifFalse:[ |
|
369 |
textView contents: newCode. |
|
370 |
] |
|
371 |
] |
|
372 |
] |
|
373 |
]. |
|
374 |
] |
|
375 |
] |
|
376 |
] |
|
377 |
] |
|
378 |
] |
|
10420 | 379 |
] |
9980 | 380 |
|
10420 | 381 |
"Created: / 29-07-2011 / 11:01:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9980 | 382 |
! ! |
383 |
||
10410 | 384 |
!CodeHighlightingService methodsFor:'registering'! |
385 |
||
386 |
registerIn: aCodeView |
|
387 |
||
388 |
super registerIn: aCodeView. |
|
10420 | 389 |
self syntaxHighlight. |
10410 | 390 |
|
391 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
392 |
! ! |
|
393 |
||
9980 | 394 |
!CodeHighlightingService class methodsFor:'documentation'! |
395 |
||
10497 | 396 |
version |
10644 | 397 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.19 2011-08-21 14:49:30 cg Exp $' |
10497 | 398 |
! |
399 |
||
9980 | 400 |
version_CVS |
10644 | 401 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.19 2011-08-21 14:49:30 cg Exp $' |
9980 | 402 |
! |
403 |
||
404 |
version_SVN |
|
405 |
^ '§Id: Tools__CodeHighlightingService.st 7715 2011-04-10 16:32:58Z vranyj1 §' |
|
406 |
! ! |