author | Claus Gittinger <cg@exept.de> |
Wed, 03 Aug 2011 16:55:32 +0200 | |
changeset 10440 | ad79e93dc9b7 |
parent 10439 | 6a41520db1be |
child 10486 | ecf02903122f |
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 |
||
78 |
!CodeHighlightingService methodsFor:'change & update'! |
|
79 |
||
80 |
update: aspect with: param from: sender |
|
81 |
||
10149 | 82 |
sender == textView modifiedChannel ifTrue:[^self codeChanged: false]. |
83 |
sender == textView model ifTrue:[^self codeChanged: true]. |
|
9980 | 84 |
sender == codeView languageHolder ifTrue:[^self codeChanged: true]. |
85 |
sender == codeView classHolder ifTrue:[^self codeChanged: true]. |
|
86 |
||
87 |
super update: aspect with: param from: sender |
|
88 |
||
89 |
"Created: / 06-03-2010 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10149 | 90 |
"Modified: / 05-07-2011 / 10:18:08 / cg" |
9980 | 91 |
! ! |
92 |
||
10420 | 93 |
!CodeHighlightingService methodsFor:'initialization'! |
94 |
||
95 |
initialize |
|
96 |
||
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
97 |
job := BackgroundJob |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
98 |
named: 'Syntax Highlighting Job' |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
99 |
on:[self syntaxHighlight: true]. |
10420 | 100 |
|
101 |
"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
|
102 |
"Modified: / 03-08-2011 / 16:47:53 / cg" |
10420 | 103 |
! ! |
104 |
||
9980 | 105 |
!CodeHighlightingService methodsFor:'private'! |
106 |
||
107 |
codeChanged: force |
|
108 |
||
109 |
(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
|
110 |
[self syntaxHighlight]. |
9980 | 111 |
|
10420 | 112 |
"Modified: / 29-07-2011 / 11:07:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9980 | 113 |
! |
114 |
||
115 |
setHighlightedCode:newCode elements: elements |
|
116 |
"the background synhighlighter has generated new colored text, |
|
117 |
with highlighted syntax. |
|
118 |
If there have been no modifications in the meantime, install it." |
|
119 |
||
10420 | 120 |
|firstShown lastShown cursorWasOn anyChange newLines l replaceAction list| |
9980 | 121 |
|
10420 | 122 |
|
9980 | 123 |
textView modified ifTrue:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
124 |
"/ new input arrived in the meantime |
9980 | 125 |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
126 |
^ self |
9980 | 127 |
]. |
10420 | 128 |
done ifFalse:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
129 |
"/ another coloring process has already been started. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
130 |
"/ ignore this (leftover) code. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
131 |
^ self |
9980 | 132 |
]. |
133 |
firstShown := textView firstLineShown. |
|
134 |
lastShown := textView lastLineShown. |
|
135 |
replaceAction := [:lNr :line | |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
136 |
|oldLine| |
9980 | 137 |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
138 |
oldLine := list at:lNr ifAbsent:nil. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
139 |
oldLine notNil ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
140 |
line notNil ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
141 |
"/ this check is needed - there is a race |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
142 |
"/ when the text is converted. This detects the |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
143 |
"/ resulting error. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
144 |
"/ Certainly a kludge. |
9980 | 145 |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
146 |
oldLine string = line string ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
147 |
oldLine emphasis ~= line emphasis ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
148 |
textView modifiedChannel removeDependent:self. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
149 |
list at:lNr put:line. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
150 |
textView modifiedChannel addDependent:self. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
151 |
(lNr between:firstShown and:lastShown) ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
152 |
anyChange ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
153 |
anyChange := true. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
154 |
cursorWasOn := textView hideCursor |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
155 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
156 |
textView redrawLine:lNr |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
157 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
158 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
159 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
160 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
161 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
162 |
]. |
10234
7cdbded1e728
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10151
diff
changeset
|
163 |
|
9980 | 164 |
anyChange := false. |
165 |
newLines := newCode asStringCollection. |
|
166 |
list := textView list. |
|
167 |
list isNil ifTrue:[ |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
168 |
textView list:newLines. |
9980 | 169 |
] ifFalse:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
170 |
"/ the cursor line first - that's where your eyes are ... |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
171 |
(l := textView cursorLine) notNil ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
172 |
l <= newLines size ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
173 |
replaceAction value:l value:(newLines at:l) |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
174 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
175 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
176 |
newLines keysAndValuesDo:replaceAction. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
177 |
anyChange ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
178 |
cursorWasOn ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
179 |
textView showCursor |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
180 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
181 |
] |
9980 | 182 |
]. |
183 |
codeView syntaxElements: elements |
|
184 |
||
185 |
"Modified: / 09-10-2006 / 11:50:17 / cg" |
|
186 |
"Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10234
7cdbded1e728
comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents:
10151
diff
changeset
|
187 |
"Modified (format): / 06-07-2011 / 18:21:12 / cg" |
10420 | 188 |
"Modified: / 29-07-2011 / 11:10:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9980 | 189 |
! |
190 |
||
191 |
showInfo: aString |
|
192 |
||
193 |
codeView showInfo: aString |
|
194 |
||
195 |
"Created: / 06-03-2010 / 19:34:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
196 |
! |
|
197 |
||
10420 | 198 |
syntaxHighlight |
9980 | 199 |
|
10420 | 200 |
|highlighterClass prio | |
9980 | 201 |
|
202 |
highlighterClass := self syntaxHighlighterClass. |
|
203 |
||
10420 | 204 |
highlighterClass isNil ifTrue:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
205 |
"No higlighter, nothing to do" |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
206 |
^self |
10420 | 207 |
]. |
9980 | 208 |
|
209 |
"/ this clobbers the codeViews modified state; therefore, we have to remember |
|
210 |
"/ this info somewhere ... |
|
10244 | 211 |
codeView browser ifNotNil:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
212 |
textView modified ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
213 |
codeView browser navigationState realModifiedState: true |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
214 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
215 |
textView modifiedChannel setValue:false. |
9980 | 216 |
]. |
217 |
||
10420 | 218 |
job scheduled ifTrue:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
219 |
job running ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
220 |
"/ process already created, but did not get a change to start yet; |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
221 |
^ self |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
222 |
] ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
223 |
job stop. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
224 |
] |
9980 | 225 |
]. |
226 |
prio := Processor userBackgroundPriority - 1. |
|
227 |
textView shown ifFalse:[ |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
228 |
prio := prio - 1 max:1 |
9980 | 229 |
]. |
10149 | 230 |
|
10420 | 231 |
job startWithPriority: prio. |
232 |
||
233 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
234 |
"Modified: / 20-07-2011 / 15:14:14 / cg" |
|
235 |
"Created: / 29-07-2011 / 11:07:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
236 |
! |
|
237 |
||
238 |
syntaxHighlight: delayed |
|
239 |
||
240 |
|oldCode oldCodeList newCode elements cls mthd highlighterClass| |
|
241 |
||
242 |
done := false. |
|
243 |
codeView syntaxElements: nil. |
|
244 |
codeView syntaxElementSelection: nil. |
|
245 |
||
246 |
highlighterClass := self syntaxHighlighterClass. |
|
10149 | 247 |
|
10420 | 248 |
cls := codeView klass. |
249 |
(cls notNil and:[cls isObsolete]) ifTrue:[ |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
250 |
cls isMeta ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
251 |
cls := (Smalltalk at:cls theNonMetaclass name) class |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
252 |
] ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
253 |
cls := Smalltalk at:cls name |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
254 |
]. |
10420 | 255 |
]. |
256 |
mthd := codeView methodHolder value. |
|
10149 | 257 |
|
10420 | 258 |
textView modified ifFalse:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
259 |
oldCodeList := textView list copy. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
260 |
textView modified ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
261 |
oldCodeList isNil ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
262 |
oldCode := oldCodeList asStringWithoutEmphasis. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
263 |
textView modified ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
264 |
Screen currentScreenQuerySignal answer:codeView device |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
265 |
do:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
266 |
Parser::ParseError handle:[:ex | |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
267 |
|errMsg| |
9980 | 268 |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
269 |
errMsg := ex description asStringCollection first asString. |
9980 | 270 |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
271 |
"/ Transcript topView raiseDeiconified. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
272 |
"/ Transcript showCR:'ParseError: ', ex description. |
9980 | 273 |
"/ self halt. |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
274 |
"/ self showInfo:(errMsg colorizeAllWith:Color red). |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
275 |
newCode := nil. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
276 |
] do:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
277 |
elements := SortedCollection new. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
278 |
codeView codeAspect == #method ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
279 |
newCode := highlighterClass formatMethod:mthd source:oldCode in:cls using: nil elementsInto: elements. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
280 |
] ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
281 |
codeView codeAspect == #expression ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
282 |
newCode := highlighterClass formatExpression:oldCode in:cls elementsInto: elements. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
283 |
] ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
284 |
codeView codeAspect == #classDefinition ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
285 |
newCode := highlighterClass formatClassDefinition:oldCode in:cls elementsInto: elements. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
286 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
287 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
288 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
289 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
290 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
291 |
newCode notNil ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
292 |
textView modified ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
293 |
newCode ~= oldCodeList ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
294 |
newCode := newCode asStringCollection. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
295 |
textView modified ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
296 |
done := true. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
297 |
textView notNil ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
298 |
"/ must add this event - and not been interrupted |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
299 |
"/ by any arriving key-event. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
300 |
"/ self showInfo:nil. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
301 |
delayed ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
302 |
codeView sensor |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
303 |
pushUserEvent:#setHighlightedCode:elements: |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
304 |
for:self |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
305 |
withArguments:(Array with:newCode with: elements). |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
306 |
"/self delayedUpdateBufferLabelWithCheckIfModified |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
307 |
] ifFalse:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
308 |
textView contents: newCode. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
309 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
310 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
311 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
312 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
313 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
314 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
315 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
316 |
] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
317 |
] |
10420 | 318 |
] |
9980 | 319 |
|
10420 | 320 |
"Created: / 29-07-2011 / 11:01:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9980 | 321 |
! |
322 |
||
323 |
syntaxHighlighterClass |
|
10149 | 324 |
| lang cls mthd | |
9980 | 325 |
|
326 |
cls := (lang := codeView languageHolder value) |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
327 |
ifNil:[nil] |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
328 |
ifNotNil:[lang syntaxHighlighterClass]. |
10149 | 329 |
|
9980 | 330 |
"Ugly hack because I don't want to branch libcomp :-)" |
10149 | 331 |
cls == SyntaxHighlighter ifTrue:[ |
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
332 |
"/ hack |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
333 |
mthd := codeView methodHolder value. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
334 |
"/ what about method-language ? |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
335 |
(mthd notNil and:[codeView browserHolder value notNil]) ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
336 |
cls := codeView browserHolder value syntaxHighlighterForMethod:mthd. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
337 |
]. |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
338 |
cls == SyntaxHighlighter ifTrue:[ |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
339 |
cls := SyntaxHighlighter2 |
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
340 |
] |
10149 | 341 |
]. |
342 |
^ cls |
|
9980 | 343 |
|
344 |
"Created: / 14-02-2010 / 12:39:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
345 |
"Modified: / 06-03-2010 / 19:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10151
8d04d7db6448
comment/format in: #startSyntaxHighlightProcess
Claus Gittinger <cg@exept.de>
parents:
10149
diff
changeset
|
346 |
"Modified: / 05-07-2011 / 11:10:11 / cg" |
9980 | 347 |
! ! |
348 |
||
10410 | 349 |
!CodeHighlightingService methodsFor:'registering'! |
350 |
||
351 |
registerIn: aCodeView |
|
352 |
||
353 |
super registerIn: aCodeView. |
|
10420 | 354 |
self syntaxHighlight. |
10410 | 355 |
|
356 |
"Created: / 27-07-2011 / 13:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
357 |
! ! |
|
358 |
||
9980 | 359 |
!CodeHighlightingService class methodsFor:'documentation'! |
360 |
||
361 |
version_CVS |
|
10440
ad79e93dc9b7
no need to access BackgroundJob via Smalltalk - the bug
Claus Gittinger <cg@exept.de>
parents:
10439
diff
changeset
|
362 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.15 2011-08-03 14:55:32 cg Exp $' |
9980 | 363 |
! |
364 |
||
365 |
version_SVN |
|
366 |
^ '§Id: Tools__CodeHighlightingService.st 7715 2011-04-10 16:32:58Z vranyj1 §' |
|
367 |
! ! |