author | Claus Gittinger <cg@exept.de> |
Sun, 30 Jun 2013 10:08:39 +0200 | |
changeset 13073 | ff2d1aceaffd |
parent 13064 | 47876055a784 |
child 13102 | 2b0609cfe5f9 |
child 13178 | c9bf900fe729 |
permissions | -rw-r--r-- |
9980 | 1 |
" |
10077 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
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 |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
31 |
instanceVariableNames:'' |
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
32 |
classVariableNames:'' |
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
33 |
poolDictionaries:'' |
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
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 |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
42 |
All Rights Reserved |
10077 | 43 |
|
44 |
Permission is hereby granted, free of charge, to any person |
|
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
9980 | 52 |
|
10077 | 53 |
The above copyright notice and this permission notice shall be |
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9980 | 64 |
" |
65 |
! ! |
|
66 |
||
67 |
!CodeHighlightingService class methodsFor:'accessing'! |
|
68 |
||
69 |
label |
|
70 |
||
71 |
"Answers short label - for UI" |
|
72 |
||
73 |
^'Syntax Highlighting' |
|
74 |
||
75 |
"Created: / 07-03-2010 / 14:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 |
! ! |
|
77 |
||
10486 | 78 |
!CodeHighlightingService methodsFor:'accessing'! |
79 |
||
80 |
syntaxHighlighter |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
81 |
| app lang highlighter | |
10486 | 82 |
|
83 |
"First, ask application..." |
|
84 |
app := codeView application. |
|
85 |
app notNil ifTrue:[ |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
86 |
| mthd class | |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
87 |
|
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
88 |
mthd := codeView methodHolder value. |
10486 | 89 |
(mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[ |
90 |
highlighter := app syntaxHighlighterForMethod:mthd. |
|
91 |
] ifFalse:[ |
|
11617 | 92 |
class := codeView classHolder value. |
10486 | 93 |
(class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[ |
94 |
highlighter := app syntaxHighlighterForClass: class. |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
95 |
] ifFalse:[ |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
96 |
(class notNil and:[app respondsTo: #syntaxHighlighter]) ifTrue:[ |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
97 |
highlighter := app syntaxHighlighterClass. |
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
98 |
]. |
10486 | 99 |
]. |
100 |
] |
|
101 |
]. |
|
102 |
"App did not provide any highlighter..." |
|
103 |
highlighter isNil ifTrue:[ |
|
11544
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
104 |
highlighter := (lang := codeView language) isNil |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
105 |
ifTrue:[nil] |
e82e2d8be007
changed: #syntaxHighlighter
Claus Gittinger <cg@exept.de>
parents:
11384
diff
changeset
|
106 |
ifFalse:[lang syntaxHighlighterClass]. |
10486 | 107 |
]. |
108 |
"HACK!!!!!!" |
|
109 |
highlighter == SyntaxHighlighter ifTrue:[ |
|
110 |
highlighter := SyntaxHighlighter2 |
|
111 |
]. |
|
112 |
^ highlighter |
|
113 |
||
114 |
"Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10729 | 115 |
"Modified: / 28-09-2011 / 00:23:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11617 | 116 |
"Modified: / 19-07-2012 / 13:03:21 / cg" |
10486 | 117 |
! |
118 |
||
119 |
syntaxHighlighters |
|
120 |
||
121 |
| highlighters | |
|
122 |
||
123 |
highlighters := OrderedCollection new: 4. |
|
124 |
||
125 |
codeView services do:[:service| |
|
126 |
| highlighter | |
|
127 |
highlighter := service syntaxHighlighter. |
|
128 |
highlighter notNil ifTrue:[ |
|
129 |
"HACK, since AbstractSyntaxHighlighter overwrite |
|
130 |
emphasis instead of adding it..." |
|
131 |
(highlighter isKindOf: AbstractSyntaxHighlighter class) ifTrue:[ |
|
132 |
highlighters addFirst: highlighter |
|
133 |
] ifFalse:[ |
|
134 |
highlighters add: highlighter |
|
135 |
]. |
|
136 |
] |
|
137 |
]. |
|
138 |
^highlighters |
|
139 |
||
140 |
"Created: / 05-08-2011 / 10:49:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11611 | 141 |
"Modified: / 19-07-2012 / 12:58:48 / cg" |
10486 | 142 |
! ! |
143 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
144 |
!CodeHighlightingService methodsFor:'acessing-defaults'! |
9980 | 145 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
146 |
defaultJobName |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
147 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
148 |
^'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
|
149 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
150 |
"Created: / 24-01-2012 / 12:06:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 151 |
! ! |
152 |
||
9980 | 153 |
!CodeHighlightingService methodsFor:'private'! |
154 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
155 |
process |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
156 |
"(Re)starts the processing job. Should be called whenever a source |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
157 |
must be (re)processed." |
9980 | 158 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
159 |
| highlighters | |
9980 | 160 |
|
10721
6813188d742b
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
10710
diff
changeset
|
161 |
(highlighters := self syntaxHighlighters) isEmptyOrNil ifTrue:[ |
10486 | 162 |
"No higlighter, nothing to do" |
10968
5e738ee1cd2a
No highlighting by default (either method or language must be set)
vrany
parents:
10961
diff
changeset
|
163 |
^self |
10420 | 164 |
]. |
9980 | 165 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
166 |
super process. |
10420 | 167 |
|
168 |
"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
|
169 |
"Modified: / 26-09-2011 / 15:40:23 / cg" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
170 |
"Created: / 24-01-2012 / 12:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10420 | 171 |
! |
172 |
||
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
173 |
process: delayed |
10486 | 174 |
|oldCode oldCodeList newCode elements cls mthd highlighterClasses| |
10420 | 175 |
|
13064
47876055a784
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
12637
diff
changeset
|
176 |
enabled == false ifTrue:[^ self]. |
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
177 |
codeView topView class == DebugView ifTrue:[^ self]. |
11617 | 178 |
|
10420 | 179 |
done := false. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
180 |
modified := false. |
10420 | 181 |
codeView syntaxElements: nil. |
182 |
codeView syntaxElementSelection: nil. |
|
183 |
||
10486 | 184 |
highlighterClasses := self syntaxHighlighters. |
10149 | 185 |
|
10420 | 186 |
cls := codeView klass. |
187 |
(cls notNil and:[cls isObsolete]) ifTrue:[ |
|
10486 | 188 |
cls isMeta ifTrue:[ |
189 |
cls := (Smalltalk at:cls theNonMetaclass name) class |
|
190 |
] ifFalse:[ |
|
191 |
cls := Smalltalk at:cls name |
|
192 |
]. |
|
10420 | 193 |
]. |
194 |
mthd := codeView methodHolder value. |
|
10149 | 195 |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
196 |
"textView" modified ifFalse:[ |
10486 | 197 |
oldCodeList := textView list copy. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
198 |
"textView" modified ifFalse:[ |
10486 | 199 |
oldCodeList isNil ifFalse:[ |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
200 |
oldCode := oldCodeList asStringCollection asStringWithoutEmphasis. |
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
201 |
"textView" modified ifFalse:[ |
10486 | 202 |
Screen currentScreenQuerySignal answer:codeView device |
203 |
do:[ |
|
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
204 |
Parser parseErrorSignal handle:[:ex | |
10486 | 205 |
|errMsg| |
9980 | 206 |
|
10486 | 207 |
errMsg := ex description asStringCollection first asString. |
9980 | 208 |
|
10486 | 209 |
"/ Transcript topView raiseDeiconified. |
210 |
"/ Transcript showCR:'ParseError: ', ex description. |
|
9980 | 211 |
"/ self halt. |
10486 | 212 |
"/ self showInfo:(errMsg colorizeAllWith:Color red). |
213 |
newCode := nil. |
|
214 |
] do:[ |
|
11705 | 215 |
|codeAspect| |
216 |
||
10486 | 217 |
elements := SortedCollection new. |
218 |
newCode := oldCode asText. |
|
11705 | 219 |
codeAspect := codeView codeAspect. |
220 |
codeAspect == SyntaxHighlighter codeAspectMethod ifTrue:[ |
|
10486 | 221 |
highlighterClasses do:[:e|newCode := e formatMethod:mthd source:newCode in:cls using: nil elementsInto: elements]. |
222 |
] ifFalse:[ |
|
11705 | 223 |
codeAspect == (SyntaxHighlighter codeAspectExpression) ifTrue:[ |
12637
9476b20e1a4c
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
12099
diff
changeset
|
224 |
highlighterClasses do:[:e|newCode := e formatStatementList:newCode in:cls elementsInto: elements]. |
10486 | 225 |
] ifFalse:[ |
11705 | 226 |
codeAspect == (SyntaxHighlighter codeAspectClassDefinition) ifTrue:[ |
11384 | 227 |
highlighterClasses do:[:e|newCode := e formatClassDefinition:newCode string in:cls elementsInto: elements]. |
10486 | 228 |
] |
229 |
]. |
|
230 |
]. |
|
231 |
] |
|
232 |
]. |
|
233 |
newCode notNil ifTrue:[ |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
234 |
"textView" modified ifFalse:[ |
10486 | 235 |
newCode ~= oldCodeList ifTrue:[ |
236 |
newCode := newCode asStringCollection. |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
237 |
"textView" modified ifFalse:[ |
10486 | 238 |
done := true. |
239 |
textView notNil ifTrue:[ |
|
240 |
"/ must add this event - and not been interrupted |
|
241 |
"/ by any arriving key-event. |
|
242 |
"/ self showInfo:nil. |
|
243 |
delayed ifTrue:[ |
|
244 |
codeView sensor |
|
245 |
pushUserEvent:#setHighlightedCode:elements: |
|
246 |
for:self |
|
247 |
withArguments:(Array with:newCode with: elements). |
|
248 |
"/self delayedUpdateBufferLabelWithCheckIfModified |
|
249 |
] ifFalse:[ |
|
250 |
textView contents: newCode. |
|
251 |
] |
|
252 |
] |
|
253 |
] |
|
254 |
]. |
|
255 |
] |
|
256 |
] |
|
257 |
] |
|
258 |
] |
|
259 |
] |
|
10420 | 260 |
] |
9980 | 261 |
|
10710
5aa37ab3189e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10701
diff
changeset
|
262 |
"Modified: / 16-09-2011 / 17:01:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
263 |
"Created: / 24-01-2012 / 12:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11705 | 264 |
"Modified: / 27-07-2012 / 22:23:16 / cg" |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
265 |
! |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
266 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
267 |
setHighlightedCode:newCode elements: elements |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
268 |
"the background synhighlighter has generated new colored text, |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
269 |
with highlighted syntax. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
270 |
If there have been no modifications in the meantime, install it." |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
271 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
272 |
|firstShown lastShown cursorWasOn anyChange newLines l replaceAction list| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
273 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
274 |
"textView" modified ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
275 |
"/ new input arrived in the meantime |
9980 | 276 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
277 |
^ self |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
278 |
]. |
11611 | 279 |
done ifFalse:[ |
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
280 |
"/ another coloring process has already been started. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
281 |
"/ ignore this (leftover) code. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
282 |
^ self |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
283 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
284 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
285 |
firstShown := textView firstLineShown. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
286 |
lastShown := textView lastLineShown. |
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 |
replaceAction := [:lNr :line | |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
289 |
|oldLine| |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
290 |
|
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
291 |
oldLine := list at:lNr ifAbsent:nil. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
292 |
oldLine notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
293 |
line notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
294 |
"/ this check is needed - there is a race |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
295 |
"/ when the text is converted. This detects the |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
296 |
"/ resulting error. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
297 |
"/ Certainly a kludge. |
10410 | 298 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
299 |
oldLine string = line string ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
300 |
oldLine emphasis ~= line emphasis ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
301 |
textView modifiedChannel removeDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
302 |
list at:lNr put:line. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
303 |
textView modifiedChannel addDependent:self. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
304 |
(lNr between:firstShown and:lastShown) ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
305 |
anyChange ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
306 |
anyChange := true. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
307 |
cursorWasOn := textView hideCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
308 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
309 |
textView redrawLine:lNr |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
310 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
311 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
312 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
313 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
314 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
315 |
]. |
10410 | 316 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
317 |
anyChange := false. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
318 |
newLines := newCode asStringCollection. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
319 |
list := textView list. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
320 |
list isNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
321 |
textView list:newLines. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
322 |
] ifFalse:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
323 |
"/ the cursor line first - that's where your eyes are ... |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
324 |
(l := textView cursorLine) notNil ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
325 |
l <= newLines size ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
326 |
replaceAction value:l value:(newLines at:l) |
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 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
329 |
newLines keysAndValuesDo:replaceAction. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
330 |
anyChange ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
331 |
cursorWasOn ifTrue:[ |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
332 |
textView showCursor |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
333 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
334 |
] |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
335 |
]. |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
336 |
codeView syntaxElements: elements |
10410 | 337 |
|
11181
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
338 |
"Modified: / 09-10-2006 / 11:50:17 / cg" |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
339 |
"Created: / 14-02-2010 / 16:10:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
f04a38c369c9
CodeView2 service refactoring: CodeHighlightingService's background
vrany
parents:
11171
diff
changeset
|
340 |
"Modified: / 16-09-2011 / 17:33:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11611 | 341 |
"Modified (format): / 19-07-2012 / 12:07:05 / cg" |
10410 | 342 |
! ! |
343 |
||
9980 | 344 |
!CodeHighlightingService class methodsFor:'documentation'! |
345 |
||
10497 | 346 |
version |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
347 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.39 2013-06-30 08:08:39 cg Exp $' |
10497 | 348 |
! |
349 |
||
9980 | 350 |
version_CVS |
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
351 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.39 2013-06-30 08:08:39 cg Exp $' |
9980 | 352 |
! |
353 |
||
354 |
version_SVN |
|
13073
ff2d1aceaffd
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
13064
diff
changeset
|
355 |
^ '$Id: Tools__CodeHighlightingService.st,v 1.39 2013-06-30 08:08:39 cg Exp $' |
9980 | 356 |
! ! |
12099
d3315fdc1c92
class: Tools::CodeHighlightingService
Claus Gittinger <cg@exept.de>
parents:
11705
diff
changeset
|
357 |