Tools__CodeNavigationService.st
author vrany
Fri, 16 Sep 2011 18:37:04 +0200
changeset 10709 e3257bcab5de
parent 10661 367196dfc3f9
child 10727 b2fc73a2b1fe
permissions -rw-r--r--
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
10076
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     2
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     3
              All Rights Reserved
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
10076
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     5
Permission is hereby granted, free of charge, to any person
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     6
obtaining a copy of this software and associated documentation
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     7
files (the 'Software'), to deal in the Software without
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     8
restriction, including without limitation the rights to use,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
     9
copy, modify, merge, publish, distribute, sublicense, and/or sell
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    10
copies of the Software, and to permit persons to whom the
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    11
Software is furnished to do so, subject to the following
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    12
conditions:
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    13
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    14
The above copyright notice and this permission notice shall be
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    15
included in all copies or substantial portions of the Software.
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    16
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    17
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    18
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    19
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    20
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    21
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    22
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    23
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    24
OTHER DEALINGS IN THE SOFTWARE.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"{ Package: 'stx:libtool' }"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"{ NameSpace: Tools }"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
CodeViewService subclass:#CodeNavigationService
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
    31
	instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis linesToRedraw'
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    32
	classVariableNames:'DefaultVariableEmphasis DefaultSelectorEmphasis'
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	poolDictionaries:''
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	category:'Interface-CodeView'
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!CodeNavigationService class methodsFor:'documentation'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
copyright
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
10076
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    41
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    42
              All Rights Reserved
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    43
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    44
Permission is hereby granted, free of charge, to any person
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    45
obtaining a copy of this software and associated documentation
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    46
files (the 'Software'), to deal in the Software without
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    47
restriction, including without limitation the rights to use,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    48
copy, modify, merge, publish, distribute, sublicense, and/or sell
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    49
copies of the Software, and to permit persons to whom the
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    50
Software is furnished to do so, subject to the following
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    51
conditions:
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
10076
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    53
The above copyright notice and this permission notice shall be
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    54
included in all copies or substantial portions of the Software.
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    55
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    56
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    57
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    58
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    59
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    60
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    61
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    62
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6d9055a907ff changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9979
diff changeset
    63
OTHER DEALINGS IN THE SOFTWARE.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!CodeNavigationService class methodsFor:'accessing'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
label
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    "Answers short label - for UI"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    ^'Semi-modal Code Navigation'
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "Created: / 07-03-2010 / 14:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10412
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    76
!
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    77
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    78
requiredServices
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    79
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    80
    ^#(#'Tools::CodeHighlightingService')
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    81
cc7a72f29805 Fixes for debugger
vrany
parents: 10361
diff changeset
    82
    "Created: / 27-07-2011 / 11:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!CodeNavigationService class methodsFor:'accessing - defaults'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
defaultSelectorEmphasis
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    88
    DefaultSelectorEmphasis isNil ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    89
        DefaultSelectorEmphasis :=
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    90
             Array with:(#backgroundColor -> (Color rgbValue:16rDBEEFF))
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    91
    ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    92
    ^ DefaultSelectorEmphasis
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    93
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    94
    "Modified: / 21-08-2011 / 09:58:18 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
defaultVariableEmphasis
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    98
    DefaultVariableEmphasis isNil ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
    99
        DefaultVariableEmphasis := Array with:(#backgroundColor -> (Color gray: 90))
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   100
    ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   101
    ^ DefaultVariableEmphasis
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "Created: / 25-06-2010 / 13:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   104
    "Modified: / 21-08-2011 / 11:04:20 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
10651
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   107
!CodeNavigationService methodsFor:'change & update'!
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   108
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   109
update: aspect with: param from: sender
10661
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   110
    sender == textView modifiedChannel ifTrue:[
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   111
        codeView reallyModified ifTrue:[
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   112
            "/ no longer highlight - the info is wrong anyway !!
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   113
            self highlightClear.
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   114
        ].
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   115
    ].
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   116
10653
0f30edd43161 changed halt to breakPoint: in #update:with:from:
vrany
parents: 10651
diff changeset
   117
    "JV: I changed 'halt' to 'breakPoint: #cg'"
10651
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   118
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   119
    "Created: / 22-08-2011 / 16:22:19 / cg"
10653
0f30edd43161 changed halt to breakPoint: in #update:with:from:
vrany
parents: 10651
diff changeset
   120
    "Modified: / 25-08-2011 / 15:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10661
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   121
    "Modified: / 05-09-2011 / 05:15:42 / cg"
10651
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   122
! !
7ab02ade36e2 added: #update:with:from:
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   123
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!CodeNavigationService methodsFor:'code services'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   126
browseClass:class 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   127
    self browser isNil ifTrue:[ ^ NewSystemBrowser browseClass:class ].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    (UserPreferences current alwaysOpenNewTabWhenCtrlClick 
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   129
        or:[ self browser navigationState modified ]) 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   130
            ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   131
                self browser 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   132
                    spawnFullBrowserInClass:class
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   133
                    selector:nil
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   134
                    in:#newBuffer
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   135
            ]
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   136
            ifFalse:[ self browser switchToClass:class ]
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "Created: / 15-02-2010 / 09:36:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "Modified: / 25-07-2010 / 11:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   140
    "Modified: / 21-08-2011 / 10:07:30 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
browser
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    ^codeView browserHolder value
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    "Created: / 06-03-2010 / 21:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
!CodeNavigationService methodsFor:'event handling'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
button1Press
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    codeView syntaxElementSelection ifNil:[^self].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    codeView syntaxElementSelection type == #selector ifTrue:[^self button1PressForSelector: codeView syntaxElementSelection value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    codeView syntaxElementSelection type == #class    ifTrue:[^self browseClass:codeView syntaxElementSelection value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    "Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    "Modified: / 06-03-2010 / 21:11:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
button1PressForSelector: selector
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    | impls menu |
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   166
    impls := codeView implementorsOf: selector.
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   167
    "/ impls size = 1 ifTrue:[^codeView browseMethod: impls anyOne].
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   168
    menu := codeView implementorsMenu: impls selector: selector.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    menu showAtPointer.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    "Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   173
    "Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10271
44c51d135362 changed: #button1PressForSelector: bug fix
vrany
parents: 10254
diff changeset
   174
    "Modified: / 07-07-2011 / 17:16:23 / jv"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   175
    "Modified: / 21-08-2011 / 11:06:08 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
button2Press
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    | sel |
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    sel := codeView syntaxElementSelection.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    (sel notNil and:[sel type == #selector]) ifTrue:[^self button2PressForSelector: sel value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    "Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "Modified: / 17-06-2011 / 08:58:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
button2PressForSelector: selector
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    | senders menu |
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   191
    senders := codeView sendersOf: selector.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   192
    "/ senders size = 1 ifTrue:[ codeView browseMethod: senders anyOne. ^ self].
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   193
    menu := codeView sendersMenu: senders selector: selector.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    menu showAtPointer.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    "Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   198
    "Modified: / 30-06-2011 / 19:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   199
    "Modified: / 21-08-2011 / 11:34:49 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   202
buttonMotion:button x:x y:y in:view 
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
     by the view."
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   206
    
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   207
    (view == textView and:[ textView sensor ctrlDown ]) ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   208
        self highlightElementAtX:x y:y.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   209
        ^ true
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   210
    ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   211
    ^ false
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "Created: / 06-03-2010 / 20:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   214
    "Modified (format): / 21-08-2011 / 10:07:15 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
buttonPress: button x:x y:y in: view
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   223
    (view == textView) ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   224
        codeView sensor ctrlDown ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   225
            button == 1      ifTrue: [self button1Press.^true].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
            button == #paste ifTrue: [self button2Press.^true].   
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   227
            button == 2      ifTrue: [self button2Press.^true]
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   228
        ].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        button == 1 ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
            self highlightVariableAtX:x y:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        ]
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   232
    ].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    ^false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "Created: / 06-03-2010 / 21:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "Modified: / 25-06-2010 / 14:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   237
    "Modified (format): / 21-08-2011 / 10:06:54 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
keyPress:key x:x y:y in:view 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "Handles an event in given view (a subview of codeView).
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   242
     If the method returns true, it has eaten the event and it will not be processed
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
     by the view."
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   244
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   245
    |ev p|
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   246
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   247
    (view ==  textView) ifTrue:[
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
        (key == #'Control_L' or:[ key == #Ctrl ]) ifTrue:[
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   249
            "/ because it is delegated, the position is not correct
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   250
            ev := WindowGroup lastEventQuerySignal query.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   251
            p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view.
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   252
            view sensor pushUserEvent:#highlightElementAtX:y: for: self withArguments:{p x. p y.}.
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   253
            ^ true.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
        ].
10661
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   255
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   256
"/        codeView reallyModified "textView modified" ifTrue:[
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   257
"/            self highlightClear. 
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   258
"/            codeView syntaxElements: nil.
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   259
"/            ^ false
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   260
"/        ].
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   261
         (key == #CursorRight
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   262
            or:[key == #CursorDown
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   263
            or:[key == #CursorLeft
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   264
            or:[key == #CursorUp]]]) ifTrue:[   
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   265
            view sensor pushUserEvent:#highlightVariableAtCursor for:self .
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   266
        ] ifFalse:[
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   267
            self highlightClear.
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   268
        ]
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   269
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    ^ false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    "Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10661
367196dfc3f9 changed:
Claus Gittinger <cg@exept.de>
parents: 10653
diff changeset
   274
    "Modified: / 05-09-2011 / 05:17:30 / cg"
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   275
    "Modified: / 16-09-2011 / 15:28:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
keyRelease: key x:x y:y in: view
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "Handles an event in given view (a subview of codeView).
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   280
     If the method returns true, it has eaten the event and it will not be processed
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   283
    |ev p|
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   284
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   285
    (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   286
        "/ because it is delegated, the position is not correct
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   287
        ev := WindowGroup lastEventQuerySignal query.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   288
        p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   289
        self highlightClear. 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   290
"/        view sensor pushUserEvent:#highlightClear for:self. 
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   291
        ^ true
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   292
    ].
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   293
    ^ false
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    "Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   296
    "Modified: / 21-08-2011 / 11:32:40 / cg"
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   297
!
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   298
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   299
linesDeletedFrom: start to: end
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   300
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   301
    self highlightClear
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   302
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   303
    "Created: / 06-07-2011 / 17:14:36 / jv"
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   304
    "Created: / 16-09-2011 / 15:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   305
!
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   306
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   307
linesInsertedFrom: start to: end
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   308
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   309
    self highlightClear
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   310
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   311
    "Created: / 06-07-2011 / 17:14:36 / jv"
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   312
    "Created: / 16-09-2011 / 15:39:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   313
!
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   314
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   315
linesModifiedFrom: start to: end
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   316
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   317
    self highlightClear
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   318
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   319
    "Created: / 06-07-2011 / 17:14:36 / jv"
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   320
    "Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
!CodeNavigationService methodsFor:'initialization'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
initialize
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    super initialize.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    selectorEmphasis := self class defaultSelectorEmphasis.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    variableEmphasis := self class defaultVariableEmphasis.
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   330
    linesToRedraw := OrderedCollection new.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    "Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
!CodeNavigationService methodsFor:'private'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
elementAtCursor
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    ^self elementAtLine: textView cursorLine col: textView cursorCol - 1
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   343
elementAtLine:line col:colArg 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   344
    |characterPosition index element col|
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   345
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   346
    "/ if beyond end of line, do not advance into next line
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   347
    col := colArg min:(textView listAt:line) size.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    characterPosition := textView characterPositionOfLine:line col:col.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    index > (codeView syntaxElements) size ifTrue:[^nil].
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   352
    element := (codeView syntaxElements) at:index ifAbsent:nil.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   353
    element notNil ifTrue:[
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   354
        (characterPosition between: element start - 1 and: element stop) ifTrue:[^element].
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   355
    ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   356
    ^nil
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   359
    "Modified: / 21-08-2011 / 11:03:29 / cg"
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   360
    "Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
elementAtX:x y:y 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
    |visibleLine line col|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   366
    codeView syntaxElements isNil ifTrue:[^nil].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   367
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    visibleLine := textView visibleLineOfY:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
    col := textView colOfX:x inVisibleLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    line := textView visibleLineToAbsoluteLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    ^self elementAtLine:line col:col
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    "Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    "Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   375
    "Modified: / 21-08-2011 / 10:26:08 / cg"
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   376
!
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   377
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   378
foo
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   379
|characterPosition index element |
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   380
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   381
characterPosition := 1
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   382
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   383
    "Created: / 21-08-2011 / 10:48:05 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
highlighEmphasisFor: element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    element ifNil:[^nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   390
    element isSelector ifTrue:[^selectorEmphasis].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   391
    element isVariable ifTrue:[^variableEmphasis].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   392
    element isSelf     ifTrue:[^variableEmphasis].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    ^nil
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   397
    "Modified: / 21-08-2011 / 09:42:37 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
highlightClear
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   402
    ^self highlightClear: true.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    "Modified: / 26-12-2007 / 12:28:05 / janfrog"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    "Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10276
068f02c67fd7 changed:
Claus Gittinger <cg@exept.de>
parents: 10271
diff changeset
   406
    "Modified: / 08-07-2011 / 08:50:45 / cg"
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   407
    "Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   410
highlightClear: redraw
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   411
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   412
    codeView syntaxElementSelection == nil ifTrue:[ ^ self ].
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   413
    textView list ifNil:[ ^ self ].
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   414
    textView list withIndexDo:[:line :lineNo | 
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   415
        line isText ifTrue:[ 
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   416
            (line hasEmphasis: currentEmphasis) ifTrue:[
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   417
                line emphasisAllRemove:currentEmphasis.
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   418
                linesToRedraw add: lineNo.
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   419
            ]
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   420
        ] 
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   421
    ].
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   422
    codeView syntaxElementSelection:nil.
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   423
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   424
    redraw ifTrue:[self redrawLines].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   426
    "Modified: / 26-12-2007 / 12:28:05 / janfrog"
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   427
    "Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   428
    "Modified: / 21-08-2011 / 10:15:15 / cg"
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   429
!
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   430
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   431
highlightElement:element 
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   432
    |e|
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   433
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   434
    codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   435
    codeView syntaxElementSelection notNil ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   436
        self highlightClear: false.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   437
    ].
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   438
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   439
    currentEmphasis := self highlighEmphasisFor:element.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   440
    element notNil ifTrue:[ 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   441
        codeView syntaxElementSelection:element.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   442
        e := element firstElementInChain.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   443
        [ e notNil ] whileTrue:[ 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   444
            self highlightWithoutClearFrom:e start to:e stop.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   445
            e := e nextElement 
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   446
        ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   447
    ].
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   448
    self redrawLines.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
    "Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   451
    "Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   452
    "Modified: / 21-08-2011 / 10:22:58 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
highlightElementAtCursor
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    self highlightElementAtLine: textView cursorLine col: textView cursorCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    "Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
    "Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
highlightElementAtLine:line col:col 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    |characterPosition index element |
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    characterPosition := textView characterPositionOfLine:line col:col.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    index > (codeView syntaxElements) size ifTrue:[^self highlightElement: nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    element := (codeView syntaxElements) at: index.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    (characterPosition between: element start and: element stop) ifFalse:[^self highlightElement: nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    self highlightElement:element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    "Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
    "Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
highlightElementAtX:x y:y 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
    |visibleLine line col|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   480
    codeView syntaxElements isNil ifTrue:[^self].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    visibleLine := textView visibleLineOfY:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
    col := textView colOfX:x inVisibleLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    line := textView visibleLineToAbsoluteLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
    self highlightElementAtLine:line col:col
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
    "Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
    "Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   488
    "Modified: / 21-08-2011 / 10:22:10 / cg"
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   489
!
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   490
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   491
highlightElementOrNil:e
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   492
    e notNil ifTrue:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   493
        "/ cg: only if selected !!
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   494
        "/ self halt.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   495
        self highlightElement:e.
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   496
    ] ifFalse:[
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   497
        self highlightClear
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   498
    ].
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   499
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   500
    "Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   501
    "Created: / 21-08-2011 / 09:56:39 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
    |line start end|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
    (lineNo between:startLine and:endLine) ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
        ^ self
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
    ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
    line := textView listAt:lineNo.
10291
af5825474e18 changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 10276
diff changeset
   511
    line isEmpty ifTrue:[^self].
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
    start := lineNo = startLine ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
                startCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
            ] ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
                line indexOfNonSeparator
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
            ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    end := lineNo = endLine ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
                endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
            ] ifFalse:[ line size ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
    line 
10291
af5825474e18 changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 10276
diff changeset
   521
        emphasisFrom:(start max: 1)
af5825474e18 changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 10276
diff changeset
   522
        to:(end min: line size)
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   523
        add: currentEmphasis.
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   524
    linesToRedraw add: lineNo.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10291
af5825474e18 changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 10276
diff changeset
   527
    "Modified: / 08-07-2011 / 13:02:51 / cg"
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   528
    "Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
highlightVariable:e 
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   532
    (e notNil and:[ e isVariableOrSelf ]) ifTrue:[
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
        self highlightElement:e.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
    ] ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
        self highlightClear.
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   536
    ].
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   537
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   538
    "Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   539
    "Modified: / 21-08-2011 / 09:39:42 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
highlightVariableAtCursor
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   543
    self highlightElementOrNil:(self elementAtCursor)
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    "Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   546
    "Modified: / 21-08-2011 / 09:56:56 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
highlightVariableAtX:x y:y 
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   550
    self highlightElementOrNil:(self elementAtX:x y:y).
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    "Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10631
7639ba8f13da fixed highlighting
Claus Gittinger <cg@exept.de>
parents: 10588
diff changeset
   553
    "Modified: / 21-08-2011 / 10:24:50 / cg"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
highlightWithoutClearFrom: start to: end
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
    "Remove underlined emphasis"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    |startLine startCol endLine endCol|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
    startLine := textView lineOfCharacterPosition:start.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    startCol := start - (textView characterPositionOfLine:startLine col:1) + 1.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    endLine := textView lineOfCharacterPosition:end.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    endCol := end - (textView characterPositionOfLine:endLine col:1) + 1.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
    self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
    "Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    textView list keysAndValuesDo:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
        [:lineNo :line|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
        |start end|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
        line isText ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
            [self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    "Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   581
!CodeNavigationService methodsFor:'redrawing'!
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   582
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   583
redrawLines
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   584
    linesToRedraw do:[:lineNo|
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   585
        textView invalidateLine: lineNo.
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   586
    ].
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   587
    linesToRedraw := OrderedCollection new: 1
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   588
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   589
    "Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10588
Claus Gittinger <cg@exept.de>
parents: 10412
diff changeset
   590
    "Modified (format): / 18-08-2011 / 16:01:34 / cg"
10361
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   591
! !
1443a20ddac2 Navigation redrawing optimized a bit...
vrany
parents: 10291
diff changeset
   592
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
!CodeNavigationService class methodsFor:'documentation'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
version_CVS
10709
e3257bcab5de Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents: 10661
diff changeset
   596
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.14 2011-09-16 16:37:04 vrany Exp $'
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
version_SVN
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    ^ '§Id: Tools__CodeNavigationService.st 7788 2011-06-17 07:57:48Z vranyj1 §'
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
! !