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