author | Patrik Svestka <patrik.svestka@gmail.com> |
Mon, 22 Nov 2021 12:32:59 +0100 | |
branch | jv |
changeset 19621 | 1cb1e6ba9f20 |
parent 19608 | 98f7cba0ce8c |
permissions | -rw-r--r-- |
9980 | 1 |
" |
10077 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
18226 | 3 |
COPYRIGHT (c) 2016 Jan Vrany |
19608
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
4 |
COPYRIGHT (c) 2021 LabWare |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
5 |
All Rights Reserved |
9980 | 6 |
|
10077 | 7 |
Permission is hereby granted, free of charge, to any person |
8 |
obtaining a copy of this software and associated documentation |
|
9 |
files (the 'Software'), to deal in the Software without |
|
10 |
restriction, including without limitation the rights to use, |
|
11 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 |
copies of the Software, and to permit persons to whom the |
|
13 |
Software is furnished to do so, subject to the following |
|
14 |
conditions: |
|
15 |
||
16 |
The above copyright notice and this permission notice shall be |
|
17 |
included in all copies or substantial portions of the Software. |
|
18 |
||
19 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
20 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
21 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
22 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
23 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
24 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
25 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9980 | 27 |
" |
28 |
"{ Package: 'stx:libtool' }" |
|
29 |
||
30 |
"{ NameSpace: Tools }" |
|
31 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
32 |
BackgroundSourceProcessingService subclass:#CodeHighlightingService |
13107 | 33 |
instanceVariableNames:'syntaxPreferences' |
13102 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
category:'Interface-CodeView' |
|
9980 | 37 |
! |
38 |
||
39 |
!CodeHighlightingService class methodsFor:'documentation'! |
|
40 |
||
41 |
copyright |
|
42 |
" |
|
10077 | 43 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
18226 | 44 |
COPYRIGHT (c) 2016 Jan Vrany |
19608
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
45 |
COPYRIGHT (c) 2021 LabWare |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
46 |
All Rights Reserved |
10077 | 47 |
|
48 |
Permission is hereby granted, free of charge, to any person |
|
49 |
obtaining a copy of this software and associated documentation |
|
50 |
files (the 'Software'), to deal in the Software without |
|
51 |
restriction, including without limitation the rights to use, |
|
52 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
53 |
copies of the Software, and to permit persons to whom the |
|
54 |
Software is furnished to do so, subject to the following |
|
55 |
conditions: |
|
9980 | 56 |
|
10077 | 57 |
The above copyright notice and this permission notice shall be |
58 |
included in all copies or substantial portions of the Software. |
|
59 |
||
60 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
61 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
62 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
63 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
64 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
65 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
66 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
67 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9980 | 68 |
" |
69 |
! ! |
|
70 |
||
19608
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
71 |
|
9980 | 72 |
!CodeHighlightingService class methodsFor:'accessing'! |
73 |
||
74 |
label |
|
13102 | 75 |
"Answers a short label - for UI" |
9980 | 76 |
|
77 |
^'Syntax Highlighting' |
|
78 |
||
79 |
"Created: / 07-03-2010 / 14:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
80 |
! ! |
|
81 |
||
13207 | 82 |
!CodeHighlightingService class methodsFor:'testing'! |
83 |
||
84 |
isUsefulFor:aCodeView |
|
85 |
"this filters useful services. |
|
86 |
Redefined to return true for myself - not for subclasses" |
|
87 |
||
88 |
^ self == Tools::CodeHighlightingService |
|
89 |
||
90 |
"Created: / 22-07-2013 / 14:00:54 / cg" |
|
91 |
! ! |
|
92 |
||
10486 | 93 |
!CodeHighlightingService methodsFor:'accessing'! |
94 |
||
13107 | 95 |
preferences:preferences |
96 |
"must be able to set those - otherwise, it uses a different coloring scheme in |
|
97 |
expecco" |
|
98 |
||
99 |
syntaxPreferences := preferences. |
|
100 |
! |
|
101 |
||
10486 | 102 |
syntaxHighlighter |
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
103 |
| app lang highlighter | |
10486 | 104 |
|
105 |
"First, ask application..." |
|
106 |
app := codeView application. |
|
107 |
app notNil ifTrue:[ |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
108 |
| mthd class | |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
109 |
|
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
110 |
mthd := codeView method. |
10486 | 111 |
(mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[ |
112 |
highlighter := app syntaxHighlighterForMethod:mthd. |
|
113 |
] ifFalse:[ |
|
11617 | 114 |
class := codeView classHolder value. |
10486 | 115 |
(class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[ |
116 |
highlighter := app syntaxHighlighterForClass: class. |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
117 |
] ifFalse:[ |
14487
ec94f1fcdf94
class: Tools::CodeHighlightingService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14486
diff
changeset
|
118 |
(app respondsTo: #syntaxHighlighter) ifTrue:[ |
14486
c8b1e2d7dc46
class: Tools::CodeHighlightingService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13867
diff
changeset
|
119 |
highlighter := app syntaxHighlighter. |
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
120 |
]. |
10486 | 121 |
]. |
122 |
] |
|
123 |
]. |
|
124 |
"App did not provide any highlighter..." |
|
125 |
highlighter isNil ifTrue:[ |
|
11544
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
126 |
highlighter := (lang := codeView language) isNil |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
127 |
ifTrue:[nil] |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
128 |
ifFalse:[lang syntaxHighlighterClass]. |
10486 | 129 |
]. |
130 |
"HACK!!!!!!" |
|
131 |
highlighter == SyntaxHighlighter ifTrue:[ |
|
132 |
highlighter := SyntaxHighlighter2 |
|
133 |
]. |
|
134 |
^ highlighter |
|
135 |
||
136 |
"Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
137 |
"Modified: / 22-07-2013 / 13:33:46 / cg" |
14487
ec94f1fcdf94
class: Tools::CodeHighlightingService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14486
diff
changeset
|
138 |
"Modified: / 10-06-2014 / 17:58:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10486 | 139 |
! |
140 |
||
141 |
syntaxHighlighters |
|
13867 | 142 |
|
143 |
| highlighters highlighter | |
|
10486 | 144 |
|
13867 | 145 |
highlighters := OrderedCollection new: 4. |
146 |
highlighter := self syntaxHighlighter. |
|
147 |
highlighter notNil ifTrue:[ |
|
15827
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
148 |
"/ cg: who sets this highlighter when adding a subclass to one of the expecco codeDescriptions? |
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
149 |
"/ highlighter class == Workflow::ExecutionEditorShellScript::NaiveShellScriptSyntaxHighlighter ifTrue:[self halt]. |
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
150 |
"/ highlighter == Workflow::ExecutionEditorShellScript::NaiveShellScriptSyntaxHighlighter ifTrue:[self halt]. |
13867 | 151 |
highlighters add: highlighter |
152 |
]. |
|
10486 | 153 |
|
14928
3c11ff12d0bc
Fixes for enabling / disabling individual CodeView2 services.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14784
diff
changeset
|
154 |
codeView servicesDo:[:service| |
13867 | 155 |
service ~~ self ifTrue:[ |
156 |
highlighter := service syntaxHighlighter. |
|
157 |
highlighter notNil ifTrue:[ |
|
15827
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
158 |
"/ cg: who sets this highlighter when adding a subclass to one of the expecco codeDescriptions? |
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
159 |
"/ highlighter class == Workflow::ExecutionEditorShellScript::NaiveShellScriptSyntaxHighlighter ifTrue:[self halt]. |
e1a8c9093e23
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15805
diff
changeset
|
160 |
"/ highlighter == Workflow::ExecutionEditorShellScript::NaiveShellScriptSyntaxHighlighter ifTrue:[self halt]. |
10486 | 161 |
highlighters add: highlighter |
162 |
]. |
|
163 |
] |
|
164 |
]. |
|
165 |
^highlighters |
|
166 |
||
167 |
"Created: / 05-08-2011 / 10:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13867 | 168 |
"Modified: / 19-07-2012 / 12:58:48 / cg" |
14928
3c11ff12d0bc
Fixes for enabling / disabling individual CodeView2 services.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14784
diff
changeset
|
169 |
"Modified: / 27-11-2014 / 15:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10486 | 170 |
! ! |
171 |
||
16762 | 172 |
!CodeHighlightingService methodsFor:'accessing-defaults'! |
9980 | 173 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
174 |
defaultJobName |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
175 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
176 |
^'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
|
177 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
178 |
"Created: / 24-01-2012 / 12:06:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 179 |
! ! |
180 |
||
9980 | 181 |
!CodeHighlightingService methodsFor:'private'! |
182 |
||
16621 | 183 |
clearScrollbarBackground |
184 |
"/ immediate change the scroller back to showing nothing; |
|
185 |
"/ will get new info, when the highlighter is finished. |
|
186 |
||
187 |
|scroller| |
|
188 |
||
189 |
codeView notNil ifTrue:[ |
|
190 |
scroller := textView superView verticalScrollBar thumb. |
|
191 |
scroller shown ifTrue:[ |
|
192 |
scroller |
|
193 |
initStyle ; |
|
194 |
invalidateRepairNow:true. |
|
195 |
] |
|
196 |
]. |
|
197 |
! |
|
198 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
199 |
process |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
200 |
"(Re)starts the processing job. Should be called whenever a source |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
201 |
must be (re)processed." |
9980 | 202 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
203 |
| highlighters | |
9980 | 204 |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
205 |
(highlighters := self syntaxHighlighters) isEmptyOrNil ifTrue:[ |
10486 | 206 |
"No higlighter, nothing to do" |
10968
5e738ee1cd2a
No highlighting by default (either method or language must be set)
vrany
parents:
10961
diff
changeset
|
207 |
^self |
10420 | 208 |
]. |
9980 | 209 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
210 |
super process. |
10420 | 211 |
|
212 |
"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
|
213 |
"Modified: / 26-09-2011 / 15:40:23 / cg" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
214 |
"Created: / 24-01-2012 / 12:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 215 |
! |
216 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
217 |
process: delayed |
13867 | 218 |
|
10486 | 219 |
|oldCode oldCodeList newCode elements cls mthd highlighterClasses| |
13588
0701806de907
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13554
diff
changeset
|
220 |
"/ codeView topView class == DebugView ifTrue:[^ self]. |
11617 | 221 |
|
10420 | 222 |
done := false. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
223 |
modified := false. |
10420 | 224 |
codeView syntaxElements: nil. |
225 |
codeView syntaxElementSelection: nil. |
|
226 |
||
10486 | 227 |
highlighterClasses := self syntaxHighlighters. |
10149 | 228 |
|
10420 | 229 |
cls := codeView klass. |
230 |
(cls notNil and:[cls isObsolete]) ifTrue:[ |
|
10486 | 231 |
cls isMeta ifTrue:[ |
232 |
cls := (Smalltalk at:cls theNonMetaclass name) class |
|
233 |
] ifFalse:[ |
|
234 |
cls := Smalltalk at:cls name |
|
235 |
]. |
|
10420 | 236 |
]. |
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
237 |
mthd := codeView method. |
10149 | 238 |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
239 |
"textView" modified ifFalse:[ |
13554
0c5bc183802b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13263
diff
changeset
|
240 |
"/ bad bad bad: textView's list may change, while we copy!!!!!!!!!! |
0c5bc183802b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13263
diff
changeset
|
241 |
[ |
0c5bc183802b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13263
diff
changeset
|
242 |
oldCodeList := textView list copy. |
0c5bc183802b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13263
diff
changeset
|
243 |
] valueUninterruptably. |
0c5bc183802b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13263
diff
changeset
|
244 |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
245 |
"textView" modified ifFalse:[ |
10486 | 246 |
oldCodeList isNil ifFalse:[ |
15805
aa12f05014e6
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15789
diff
changeset
|
247 |
oldCode := oldCodeList asStringCollection asStringWithoutEmphasis. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
248 |
"textView" modified ifFalse:[ |
10486 | 249 |
Screen currentScreenQuerySignal answer:codeView device |
250 |
do:[ |
|
17166 | 251 |
"/ cg: not a good idea to handle it here; |
15447
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
252 |
"/ Syntaxhighlighter does it also, and will generate a better colorized string |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
253 |
"/ Parser parseErrorSignal handle:[:ex | |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
254 |
"/ |errMsg| |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
255 |
"/ |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
256 |
"/ errMsg := ex description asStringCollection first asString. |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
257 |
"/ |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
258 |
"/ "/ Transcript topView raiseDeiconified. |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
259 |
"/ Transcript showCR:'Error caught: ', ex description. |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
260 |
"/ "/ self halt. |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
261 |
"/ "/ self showInfo:(errMsg colorizeAllWith:Color red). |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
262 |
"/ newCode := nil. |
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
263 |
"/ ] do:[ |
13867 | 264 |
| codeAspect | |
265 |
||
266 |
elements := ParseTreeIndex new. |
|
10486 | 267 |
newCode := oldCode asText. |
11705 | 268 |
codeAspect := codeView codeAspect. |
269 |
codeAspect == SyntaxHighlighter codeAspectMethod ifTrue:[ |
|
13107 | 270 |
highlighterClasses do:[:e|newCode := e formatMethod:mthd source:newCode in:cls using:syntaxPreferences elementsInto: elements]. |
10486 | 271 |
] ifFalse:[ |
11705 | 272 |
codeAspect == (SyntaxHighlighter codeAspectExpression) ifTrue:[ |
13867 | 273 |
highlighterClasses do:[:e|newCode := e formatExpression:newCode in:cls elementsInto: elements]. |
10486 | 274 |
] ifFalse:[ |
11705 | 275 |
codeAspect == (SyntaxHighlighter codeAspectClassDefinition) ifTrue:[ |
11384 | 276 |
highlighterClasses do:[:e|newCode := e formatClassDefinition:newCode string in:cls elementsInto: elements]. |
16128
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
277 |
] ifFalse:[ |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
278 |
codeAspect == (SyntaxHighlighter codeAspectStatements) ifTrue:[ |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
279 |
highlighterClasses do:[:e|newCode := e formatStatements:newCode string in:cls elementsInto: elements]. |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
280 |
] |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
281 |
]. |
10486 | 282 |
]. |
283 |
]. |
|
15447
1bad1d4218b5
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15094
diff
changeset
|
284 |
"/ ] |
10486 | 285 |
]. |
286 |
newCode notNil ifTrue:[ |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
287 |
"textView" modified ifFalse:[ |
10486 | 288 |
newCode ~= oldCodeList ifTrue:[ |
289 |
newCode := newCode asStringCollection. |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
290 |
"textView" modified ifFalse:[ |
10486 | 291 |
done := true. |
292 |
textView notNil ifTrue:[ |
|
293 |
"/ must add this event - and not been interrupted |
|
294 |
"/ by any arriving key-event. |
|
295 |
"/ self showInfo:nil. |
|
296 |
delayed ifTrue:[ |
|
297 |
codeView sensor |
|
298 |
pushUserEvent:#setHighlightedCode:elements: |
|
299 |
for:self |
|
300 |
withArguments:(Array with:newCode with: elements). |
|
301 |
"/self delayedUpdateBufferLabelWithCheckIfModified |
|
302 |
] ifFalse:[ |
|
303 |
textView contents: newCode. |
|
13867 | 304 |
codeView syntaxElements: elements. |
305 |
gutterView invalidate. |
|
16621 | 306 |
codeView updateScrollersViewBackground. |
10486 | 307 |
] |
308 |
] |
|
309 |
] |
|
310 |
]. |
|
311 |
] |
|
312 |
] |
|
313 |
] |
|
314 |
] |
|
315 |
] |
|
10420 | 316 |
] |
9980 | 317 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
318 |
"Created: / 24-01-2012 / 12:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13200
74d83643473b
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13107
diff
changeset
|
319 |
"Modified: / 22-07-2013 / 13:33:40 / cg" |
16128
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
320 |
"Modified: / 22-02-2016 / 21:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
321 |
! |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
322 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
323 |
setHighlightedCode:newCode elements: elements |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
324 |
"the background synhighlighter has generated new colored text, |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
325 |
with highlighted syntax. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
326 |
If there have been no modifications in the meantime, install it." |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
327 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
328 |
|firstShown lastShown cursorWasOn anyChange newLines l replaceAction list| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
329 |
|
14784
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
330 |
"/ It may happen that service is unregistered while |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
331 |
"/ an user event for #setHighlightedCode:elements: is already in |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
332 |
"/ an event queue but not yet processed. To handle this situation. |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
333 |
"/ check if textView is nil (which is in case the service is unregistered) |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
334 |
textView isNil ifTrue:[ ^ self ]. |
9980 | 335 |
|
14784
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
336 |
|
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
337 |
modified ifTrue:[ |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
338 |
"/ a new input arrived in the meantime |
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
339 |
^ self |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
340 |
]. |
14784
0e0fc09a7a62
BrowserEnvironment is now polymorphic with ParseTreeEnvironment
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14487
diff
changeset
|
341 |
|
11611 | 342 |
done ifFalse:[ |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
343 |
"/ another coloring process has already been started. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
344 |
"/ ignore this (leftover) code. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
345 |
^ self |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
346 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
347 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
348 |
firstShown := textView firstLineShown. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
349 |
lastShown := textView lastLineShown. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
350 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
351 |
replaceAction := [:lNr :line | |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
352 |
|oldLine| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
353 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
354 |
oldLine := list at:lNr ifAbsent:nil. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
355 |
oldLine notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
356 |
line notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
357 |
"/ this check is needed - there is a race |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
358 |
"/ when the text is converted. This detects the |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
359 |
"/ resulting error. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
360 |
"/ Certainly a kludge. |
10410 | 361 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
362 |
oldLine string = line string ifTrue:[ |
13867 | 363 |
| i | |
364 |
||
365 |
"JV@2012-02-01: Remove any emphasis on leading whitespace" |
|
366 |
"(presumably created by LintHighlighter)" |
|
367 |
i := line string indexOfNonSeparator. |
|
368 |
i > 1 ifTrue:[ |
|
369 |
| e | |
|
370 |
||
371 |
(e := (line emphasisAt: i - 1)) notNil ifTrue:[ |
|
372 |
line emphasisFrom: 1 to: i - 1 remove: e. |
|
373 |
] |
|
374 |
]. |
|
375 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
376 |
oldLine emphasis ~= line emphasis ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
377 |
textView modifiedChannel removeDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
378 |
list at:lNr put:line. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
379 |
textView modifiedChannel addDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
380 |
(lNr between:firstShown and:lastShown) ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
381 |
anyChange ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
382 |
anyChange := true. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
383 |
cursorWasOn := textView hideCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
384 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
385 |
textView redrawLine:lNr |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
386 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
387 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
388 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
389 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
390 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
391 |
]. |
10410 | 392 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
393 |
anyChange := false. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
394 |
newLines := newCode asStringCollection. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
395 |
list := textView list. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
396 |
list isNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
397 |
textView list:newLines. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
398 |
] ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
399 |
"/ the cursor line first - that's where your eyes are ... |
15094
7e80c05b797b
Fix in Tools::CodeHighlightingService>>#setHighlightedCode:elements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14928
diff
changeset
|
400 |
((l := textView cursorLine) notNil and:[l between: 1 and: newLines size]) ifTrue:[ |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
401 |
l <= newLines size ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
402 |
replaceAction value:l value:(newLines at:l) |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
403 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
404 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
405 |
newLines keysAndValuesDo:replaceAction. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
406 |
anyChange ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
407 |
cursorWasOn ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
408 |
textView showCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
409 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
410 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
411 |
]. |
13867 | 412 |
codeView syntaxElements: elements. |
413 |
gutterView invalidate. |
|
16621 | 414 |
codeView updateScrollersViewBackground. |
415 |
||
13867 | 416 |
"/ Transcript showCR:'--> rehighlighted ', self identityHash printString. |
10410 | 417 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
418 |
"Modified: / 09-10-2006 / 11:50:17 / cg" |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
419 |
"Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13867 | 420 |
"Modified (format): / 21-08-2011 / 09:38:22 / cg" |
421 |
"Modified: / 01-02-2012 / 19:18:00 / jv" |
|
15094
7e80c05b797b
Fix in Tools::CodeHighlightingService>>#setHighlightedCode:elements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14928
diff
changeset
|
422 |
"Modified: / 20-01-2015 / 15:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10410 | 423 |
! ! |
424 |
||
19608
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
425 |
!CodeHighlightingService methodsFor:'registering'! |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
426 |
|
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
427 |
registerIn: aCodeView |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
428 |
|
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
429 |
super registerIn: aCodeView. |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
430 |
textView addDependent: self. |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
431 |
syntaxPreferences := aCodeView theme |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
432 |
|
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
433 |
"Created: / 15-09-2021 / 21:16:47 / Jan Vrany <jan.vrany@labware.com>" |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
434 |
! ! |
98f7cba0ce8c
Theming: add support for theming navigation service's styles
Jan Vrany <jan.vrany@labware.com>
parents:
18532
diff
changeset
|
435 |
|
9980 | 436 |
!CodeHighlightingService class methodsFor:'documentation'! |
437 |
||
10497 | 438 |
version |
15789
3c5227646c1f
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15447
diff
changeset
|
439 |
^ '$Header$' |
10497 | 440 |
! |
441 |
||
9980 | 442 |
version_CVS |
15789
3c5227646c1f
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15447
diff
changeset
|
443 |
^ '$Header$' |
9980 | 444 |
! |
445 |
||
16128
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
446 |
version_HG |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
447 |
|
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
448 |
^ '$Changeset: <not expanded> $' |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
449 |
! |
e7b59cfeb8f3
Added support for highlighting of a statement list
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15828
diff
changeset
|
450 |
|
9980 | 451 |
version_SVN |
15789
3c5227646c1f
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
15447
diff
changeset
|
452 |
^ '$Id$' |
9980 | 453 |
! ! |
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
454 |