Tools__CodeHighlightingService.st
author Claus Gittinger <cg@exept.de>
Wed, 03 Aug 2011 16:47:58 +0200
changeset 10439 6a41520db1be
parent 10438 bd3f0c062ac3
child 10440 ad79e93dc9b7
permissions -rw-r--r--
variable renamed in: #initialize
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
d2b07a20c425 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9980
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
d2b07a20c425 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9980
diff changeset
    42
              All Rights Reserved
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
10438
bd3f0c062ac3 variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents: 10434
diff changeset
    97
    job := Smalltalk::BackgroundJob 
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
    98
            named: 'Syntax Highlighting Job' 
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
    99
            on:[self syntaxHighlight: true].
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:
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
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:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        "/ new input arrived in the meantime
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        ^ self
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:[
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        "/ another coloring process has already been started.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        "/ ignore this (leftover) code.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        ^ self
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 |
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
            |oldLine|
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
            oldLine := list at:lNr ifAbsent:nil.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
            oldLine notNil ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                line notNil ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                    "/ this check is needed - there is a race
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
                    "/ when the text is converted. This detects the
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                    "/ resulting error.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                    "/ Certainly a kludge.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                    oldLine string = line string ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                        oldLine emphasis ~= line emphasis ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                            textView modifiedChannel removeDependent:self.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                            list at:lNr put:line.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                            textView modifiedChannel addDependent:self.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                            (lNr between:firstShown and:lastShown) ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                                anyChange ifFalse:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
                                    anyChange := true.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                                    cursorWasOn := textView hideCursor
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                ].
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                                textView redrawLine:lNr
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                            ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                        ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                    ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
            ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
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:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
        textView list:newLines.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    ] ifFalse:[
10234
7cdbded1e728 comment/format in: #setHighlightedCode:elements:
Claus Gittinger <cg@exept.de>
parents: 10151
diff changeset
   170
        "/ the cursor line first - that's where your eyes are ...
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
        (l := textView cursorLine) notNil ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
            l <= newLines size ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
                replaceAction value:l value:(newLines at:l)
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
            ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
        ].
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
        newLines keysAndValuesDo:replaceAction.
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        anyChange ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
            cursorWasOn ifTrue:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
                textView showCursor
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
            ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
        ]
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:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   205
        "No higlighter, nothing to do"
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   206
        ^self
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:[
9dac22861b94 Attempt to fix the accept/cancel bar - no success.
vrany
parents: 10234
diff changeset
   212
        textView modified ifTrue:[
9dac22861b94 Attempt to fix the accept/cancel bar - no success.
vrany
parents: 10234
diff changeset
   213
            codeView browser navigationState realModifiedState: true
9dac22861b94 Attempt to fix the accept/cancel bar - no success.
vrany
parents: 10234
diff changeset
   214
        ].
9dac22861b94 Attempt to fix the accept/cancel bar - no success.
vrany
parents: 10234
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:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   219
        job running ifFalse:[
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
            "/ process already created, but did not get a change to start yet;
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
            ^ self
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   222
        ] ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   223
            job stop.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
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:[
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
        prio := prio - 1 max:1
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:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   250
        cls isMeta ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   251
            cls := (Smalltalk at:cls theNonMetaclass name) class
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   252
        ] ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   253
            cls := Smalltalk at:cls name
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   254
        ].
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:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   259
        oldCodeList := textView list copy.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   260
        textView modified ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   261
            oldCodeList isNil ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   262
                oldCode := oldCodeList asStringWithoutEmphasis.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   263
                textView modified ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   264
                    Screen currentScreenQuerySignal answer:codeView device
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   265
                    do:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   266
                        Parser::ParseError handle:[:ex |
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   267
                            |errMsg|
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   269
                            errMsg := ex description asStringCollection first asString.
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   271
                            "/ Transcript topView raiseDeiconified.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   272
                            "/ Transcript showCR:'ParseError: ', ex description.
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
"/ self halt.
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   274
                            "/ self showInfo:(errMsg colorizeAllWith:Color red).
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   275
                            newCode := nil.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   276
                        ] do:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   277
                            elements := SortedCollection new.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   278
                            codeView codeAspect == #method ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   279
                                newCode := highlighterClass formatMethod:mthd source:oldCode in:cls using: nil elementsInto: elements.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   280
                            ] ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   281
                                codeView codeAspect == #expression ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   282
                                    newCode := highlighterClass formatExpression:oldCode in:cls elementsInto: elements.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   283
                                ] ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   284
                                    codeView codeAspect == #classDefinition ifTrue:[                                            
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   285
                                        newCode := highlighterClass formatClassDefinition:oldCode in:cls elementsInto: elements.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   286
                                    ]
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   287
                                ].
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   288
                            ].
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   289
                        ]
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   290
                    ].
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   291
                    newCode notNil ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   292
                        textView modified ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   293
                            newCode ~= oldCodeList ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   294
                                newCode := newCode asStringCollection.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   295
                                textView modified ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   296
                                    done := true.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   297
                                    textView notNil ifTrue:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   298
                                        "/ must add this event - and not been interrupted
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   299
                                        "/ by any arriving key-event.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   300
                                        "/ self showInfo:nil.
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   301
                                        delayed ifTrue:[                                                
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   302
                                            codeView sensor
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   303
                                                pushUserEvent:#setHighlightedCode:elements:
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   304
                                                for:self
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   305
                                                withArguments:(Array with:newCode with: elements).
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   306
                                                "/self delayedUpdateBufferLabelWithCheckIfModified
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   307
                                        ] ifFalse:[
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   308
                                            textView contents: newCode.
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                                        ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                                    ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
                                ]
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   312
                            ].
9980
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
                        ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
                    ]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                ]
10420
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   316
            ]
ed96d3da2be7 - CodeHighlightingService refactored to use
vrany
parents: 10410
diff changeset
   317
        ]
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)
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
                ifNil:[nil]
cf0d7a8b54e9 initial checkin
Claus Gittinger <cg@exept.de>
parents:
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:[
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   332
        "/ hack
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   333
        mthd := codeView methodHolder value.
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   334
        "/ what about method-language ?
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   335
        (mthd notNil and:[codeView browserHolder value notNil]) ifTrue:[
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   336
            cls := codeView browserHolder value syntaxHighlighterForMethod:mthd.
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   337
        ].
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   338
        cls == SyntaxHighlighter ifTrue:[
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   339
            cls := SyntaxHighlighter2
d390c010293f changed:
Claus Gittinger <cg@exept.de>
parents: 10077
diff changeset
   340
        ]
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
10439
6a41520db1be variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents: 10438
diff changeset
   362
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.14 2011-08-03 14:47:58 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
! !