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