author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 04 Sep 2013 11:33:19 +0100 | |
branch | jv |
changeset 13491 | b3afe831ff0a |
parent 13289 | cc75e3cd0362 |
child 13609 | 8b400fde34ef |
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 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
30 |
BackgroundSourceProcessingService subclass:#CodeHighlightingService |
13107 | 31 |
instanceVariableNames:'syntaxPreferences' |
13102 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
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 |
|
13102 | 70 |
"Answers a short label - for UI" |
9980 | 71 |
|
72 |
^'Syntax Highlighting' |
|
73 |
||
74 |
"Created: / 07-03-2010 / 14:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
75 |
! ! |
|
76 |
||
13207 | 77 |
!CodeHighlightingService class methodsFor:'testing'! |
78 |
||
79 |
isUsefulFor:aCodeView |
|
80 |
"this filters useful services. |
|
81 |
Redefined to return true for myself - not for subclasses" |
|
82 |
||
83 |
^ self == Tools::CodeHighlightingService |
|
84 |
||
85 |
"Created: / 22-07-2013 / 14:00:54 / cg" |
|
86 |
! ! |
|
87 |
||
10486 | 88 |
!CodeHighlightingService methodsFor:'accessing'! |
89 |
||
13107 | 90 |
preferences:preferences |
91 |
"must be able to set those - otherwise, it uses a different coloring scheme in |
|
92 |
expecco" |
|
93 |
||
94 |
syntaxPreferences := preferences. |
|
95 |
! |
|
96 |
||
10486 | 97 |
syntaxHighlighter |
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
98 |
| app lang highlighter | |
10486 | 99 |
|
100 |
"First, ask application..." |
|
101 |
app := codeView application. |
|
102 |
app notNil ifTrue:[ |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
103 |
| mthd class | |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
104 |
|
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
105 |
mthd := codeView method. |
10486 | 106 |
(mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[ |
107 |
highlighter := app syntaxHighlighterForMethod:mthd. |
|
108 |
] ifFalse:[ |
|
11617 | 109 |
class := codeView classHolder value. |
10486 | 110 |
(class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[ |
111 |
highlighter := app syntaxHighlighterForClass: class. |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
112 |
] ifFalse:[ |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
113 |
(class notNil and:[app respondsTo: #syntaxHighlighter]) ifTrue:[ |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
114 |
highlighter := app syntaxHighlighterClass. |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
115 |
]. |
10486 | 116 |
]. |
117 |
] |
|
118 |
]. |
|
119 |
"App did not provide any highlighter..." |
|
120 |
highlighter isNil ifTrue:[ |
|
11544
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
121 |
highlighter := (lang := codeView language) isNil |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
122 |
ifTrue:[nil] |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
123 |
ifFalse:[lang syntaxHighlighterClass]. |
10486 | 124 |
]. |
125 |
"HACK!!!!!!" |
|
126 |
highlighter == SyntaxHighlighter ifTrue:[ |
|
127 |
highlighter := SyntaxHighlighter2 |
|
128 |
]. |
|
129 |
^ highlighter |
|
130 |
||
131 |
"Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10729 | 132 |
"Modified: / 28-09-2011 / 00:23:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
133 |
"Modified: / 22-07-2013 / 13:33:46 / cg" |
10486 | 134 |
! |
135 |
||
136 |
syntaxHighlighters |
|
137 |
||
12803
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
138 |
| highlighters highlighter | |
10486 | 139 |
|
140 |
highlighters := OrderedCollection new: 4. |
|
12803
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
141 |
highlighter := self syntaxHighlighter. |
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
142 |
highlighter notNil ifTrue:[ |
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
143 |
highlighters add: highlighter |
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
144 |
]. |
10486 | 145 |
|
146 |
codeView services do:[:service| |
|
12803
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
147 |
service ~~ self ifTrue:[ |
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
148 |
highlighter := service syntaxHighlighter. |
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
149 |
highlighter notNil ifTrue:[ |
10486 | 150 |
highlighters add: highlighter |
151 |
]. |
|
152 |
] |
|
153 |
]. |
|
154 |
^highlighters |
|
155 |
||
156 |
"Created: / 05-08-2011 / 10:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11611 | 157 |
"Modified: / 19-07-2012 / 12:58:48 / cg" |
12803
81c08c951292
Fix in Tools::CodeHighlightingService>>#syntaxHighlighters.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12650
diff
changeset
|
158 |
"Modified: / 23-04-2013 / 01:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10486 | 159 |
! ! |
160 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
161 |
!CodeHighlightingService methodsFor:'acessing-defaults'! |
9980 | 162 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
163 |
defaultJobName |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
164 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
165 |
^'CodeView2''s syntax highlighting job' |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
166 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
167 |
"Created: / 24-01-2012 / 12:06:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 168 |
! ! |
169 |
||
9980 | 170 |
!CodeHighlightingService methodsFor:'private'! |
171 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
172 |
process |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
173 |
"(Re)starts the processing job. Should be called whenever a source |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
174 |
must be (re)processed." |
9980 | 175 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
176 |
| highlighters | |
9980 | 177 |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
178 |
(highlighters := self syntaxHighlighters) isEmptyOrNil ifTrue:[ |
10486 | 179 |
"No higlighter, nothing to do" |
10968
5e738ee1cd2a
No highlighting by default (either method or language must be set)
vrany
parents:
10961
diff
changeset
|
180 |
^self |
10420 | 181 |
]. |
9980 | 182 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
183 |
super process. |
10420 | 184 |
|
185 |
"Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
10968
5e738ee1cd2a
No highlighting by default (either method or language must be set)
vrany
parents:
10961
diff
changeset
|
186 |
"Modified: / 26-09-2011 / 15:40:23 / cg" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
187 |
"Created: / 24-01-2012 / 12:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 188 |
! |
189 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
190 |
process: delayed |
10420 | 191 |
|
10486 | 192 |
|oldCode oldCodeList newCode elements cls mthd highlighterClasses| |
10420 | 193 |
|
194 |
done := false. |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
195 |
modified := false. |
10420 | 196 |
codeView syntaxElements: nil. |
197 |
codeView syntaxElementSelection: nil. |
|
198 |
||
10486 | 199 |
highlighterClasses := self syntaxHighlighters. |
10149 | 200 |
|
10420 | 201 |
cls := codeView klass. |
202 |
(cls notNil and:[cls isObsolete]) ifTrue:[ |
|
10486 | 203 |
cls isMeta ifTrue:[ |
204 |
cls := (Smalltalk at:cls theNonMetaclass name) class |
|
205 |
] ifFalse:[ |
|
206 |
cls := Smalltalk at:cls name |
|
207 |
]. |
|
10420 | 208 |
]. |
209 |
mthd := codeView methodHolder value. |
|
10149 | 210 |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
211 |
"textView" modified ifFalse:[ |
10486 | 212 |
oldCodeList := textView list copy. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
213 |
"textView" modified ifFalse:[ |
10486 | 214 |
oldCodeList isNil ifFalse:[ |
215 |
oldCode := oldCodeList asStringWithoutEmphasis. |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
216 |
"textView" modified ifFalse:[ |
10486 | 217 |
Screen currentScreenQuerySignal answer:codeView device |
218 |
do:[ |
|
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
219 |
Parser parseErrorSignal handle:[:ex | |
10486 | 220 |
|errMsg| |
9980 | 221 |
|
10486 | 222 |
errMsg := ex description asStringCollection first asString. |
9980 | 223 |
|
10486 | 224 |
"/ Transcript topView raiseDeiconified. |
225 |
"/ Transcript showCR:'ParseError: ', ex description. |
|
9980 | 226 |
"/ self halt. |
10486 | 227 |
"/ self showInfo:(errMsg colorizeAllWith:Color red). |
228 |
newCode := nil. |
|
229 |
] do:[ |
|
12287 | 230 |
| codeAspect | |
231 |
||
12170
6c9c4b7981ee
branch jv-experiments merged back
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12138
diff
changeset
|
232 |
elements := ParseTreeIndex new. |
10486 | 233 |
newCode := oldCode asText. |
11705 | 234 |
codeAspect := codeView codeAspect. |
235 |
codeAspect == SyntaxHighlighter codeAspectMethod ifTrue:[ |
|
13107 | 236 |
highlighterClasses do:[:e|newCode := e formatMethod:mthd source:newCode in:cls using:syntaxPreferences elementsInto: elements]. |
10486 | 237 |
] ifFalse:[ |
11705 | 238 |
codeAspect == (SyntaxHighlighter codeAspectExpression) ifTrue:[ |
10486 | 239 |
highlighterClasses do:[:e|newCode := e formatExpression:newCode in:cls elementsInto: elements]. |
240 |
] ifFalse:[ |
|
241 |
codeView codeAspect == #classDefinition ifTrue:[ |
|
242 |
highlighterClasses do:[:e|newCode := e formatClassDefinition:newCode in:cls elementsInto: elements]. |
|
243 |
] |
|
244 |
]. |
|
245 |
]. |
|
246 |
] |
|
247 |
]. |
|
248 |
newCode notNil ifTrue:[ |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
249 |
"textView" modified ifFalse:[ |
10486 | 250 |
newCode ~= oldCodeList ifTrue:[ |
251 |
newCode := newCode asStringCollection. |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
252 |
"textView" modified ifFalse:[ |
10486 | 253 |
done := true. |
254 |
textView notNil ifTrue:[ |
|
255 |
"/ must add this event - and not been interrupted |
|
256 |
"/ by any arriving key-event. |
|
257 |
"/ self showInfo:nil. |
|
258 |
delayed ifTrue:[ |
|
259 |
codeView sensor |
|
260 |
pushUserEvent:#setHighlightedCode:elements: |
|
261 |
for:self |
|
262 |
withArguments:(Array with:newCode with: elements). |
|
263 |
"/self delayedUpdateBufferLabelWithCheckIfModified |
|
264 |
] ifFalse:[ |
|
265 |
textView contents: newCode. |
|
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12170
diff
changeset
|
266 |
codeView syntaxElements: elements. |
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12170
diff
changeset
|
267 |
gutterView invalidate. |
10486 | 268 |
] |
269 |
] |
|
270 |
] |
|
271 |
]. |
|
272 |
] |
|
273 |
] |
|
274 |
] |
|
275 |
] |
|
276 |
] |
|
10420 | 277 |
] |
9980 | 278 |
|
12125 | 279 |
"Modified: / 22-08-2011 / 14:17:47 / cg" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
280 |
"Created: / 24-01-2012 / 12:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
281 |
! |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
282 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
283 |
setHighlightedCode:newCode elements: elements |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
284 |
"the background synhighlighter has generated new colored text, |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
285 |
with highlighted syntax. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
286 |
If there have been no modifications in the meantime, install it." |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
287 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
288 |
|firstShown lastShown cursorWasOn anyChange newLines l replaceAction list| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
289 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
290 |
"textView" modified ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
291 |
"/ new input arrived in the meantime |
9980 | 292 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
293 |
^ self |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
294 |
]. |
11611 | 295 |
done ifFalse:[ |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
296 |
"/ another coloring process has already been started. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
297 |
"/ ignore this (leftover) code. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
298 |
^ self |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
299 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
300 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
301 |
firstShown := textView firstLineShown. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
302 |
lastShown := textView lastLineShown. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
303 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
304 |
replaceAction := [:lNr :line | |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
305 |
|oldLine| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
306 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
307 |
oldLine := list at:lNr ifAbsent:nil. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
308 |
oldLine notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
309 |
line notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
310 |
"/ this check is needed - there is a race |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
311 |
"/ when the text is converted. This detects the |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
312 |
"/ resulting error. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
313 |
"/ Certainly a kludge. |
10410 | 314 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
315 |
oldLine string = line string ifTrue:[ |
12138
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
316 |
| i | |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
317 |
|
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
318 |
"JV@2012-02-01: Remove any emphasis on leading whitespace" |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
319 |
"(presumably created by LintHighlighter)" |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
320 |
i := line string indexOfNonSeparator. |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
321 |
i > 1 ifTrue:[ |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
322 |
| e | |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
323 |
|
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
324 |
(e := (line emphasisAt: i - 1)) notNil ifTrue:[ |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
325 |
line emphasisFrom: 1 to: i - 1 remove: e. |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
326 |
] |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
327 |
]. |
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
328 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
329 |
oldLine emphasis ~= line emphasis ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
330 |
textView modifiedChannel removeDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
331 |
list at:lNr put:line. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
332 |
textView modifiedChannel addDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
333 |
(lNr between:firstShown and:lastShown) ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
334 |
anyChange ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
335 |
anyChange := true. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
336 |
cursorWasOn := textView hideCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
337 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
338 |
textView redrawLine:lNr |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
339 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
340 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
341 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
342 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
343 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
344 |
]. |
10410 | 345 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
346 |
anyChange := false. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
347 |
newLines := newCode asStringCollection. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
348 |
list := textView list. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
349 |
list isNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
350 |
textView list:newLines. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
351 |
] ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
352 |
"/ the cursor line first - that's where your eyes are ... |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
353 |
(l := textView cursorLine) notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
354 |
l <= newLines size ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
355 |
replaceAction value:l value:(newLines at:l) |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
356 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
357 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
358 |
newLines keysAndValuesDo:replaceAction. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
359 |
anyChange ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
360 |
cursorWasOn ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
361 |
textView showCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
362 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
363 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
364 |
]. |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
365 |
codeView syntaxElements: elements. |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
366 |
gutterView invalidate. |
10410 | 367 |
|
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12170
diff
changeset
|
368 |
"/ Transcript showCR:'--> rehighlighted ', self identityHash printString. |
10410 | 369 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
370 |
"Modified: / 09-10-2006 / 11:50:17 / cg" |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
371 |
"Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12125 | 372 |
"Modified (format): / 21-08-2011 / 09:38:22 / cg" |
12138
84205b6b75b4
Tools::CodeHighlightingService: remove emphasis from leading whitespace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
373 |
"Modified: / 01-02-2012 / 19:18:00 / jv" |
12194
4639848e5517
Improvements in syntax highlighting
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12170
diff
changeset
|
374 |
"Modified: / 17-03-2012 / 19:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10410 | 375 |
! ! |
376 |
||
9980 | 377 |
!CodeHighlightingService class methodsFor:'documentation'! |
378 |
||
10497 | 379 |
version |
13263
a6c32c37bf38
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13207
diff
changeset
|
380 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.44 2013-07-30 17:35:09 cg Exp $' |
10497 | 381 |
! |
382 |
||
9980 | 383 |
version_CVS |
13263
a6c32c37bf38
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13207
diff
changeset
|
384 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.44 2013-07-30 17:35:09 cg Exp $' |
9980 | 385 |
! |
386 |
||
12431
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12401
diff
changeset
|
387 |
version_HG |
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12401
diff
changeset
|
388 |
|
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12401
diff
changeset
|
389 |
^ '$Changeset: <not expanded> $' |
9980 | 390 |
! |
391 |
||
392 |
version_SVN |
|
13263
a6c32c37bf38
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13207
diff
changeset
|
393 |
^ '$Id: Tools__CodeHighlightingService.st,v 1.44 2013-07-30 17:35:09 cg Exp $' |
9980 | 394 |
! ! |
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
395 |