Tools__CodeNavigationService.st
author vrany
Thu, 07 Jul 2011 18:17:21 +0200
changeset 10271 44c51d135362
parent 10254 43001ebe1490
child 10276 068f02c67fd7
permissions -rw-r--r--
changed: #button1PressForSelector: bug fix
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
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis'
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	classVariableNames:''
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>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!CodeNavigationService class methodsFor:'accessing - defaults'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
defaultSelectorEmphasis
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    ^ Array with:#backgroundColor 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
                -> (Color white blendWith:(Color 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
                                redByte:100
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
                                greenByte:180
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
                                blueByte:255))
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
defaultVariableEmphasis
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ^ Array with:#backgroundColor 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
                -> (Color gray: 90)
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "Created: / 25-06-2010 / 13:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!CodeNavigationService methodsFor:'code services'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
browseClass: class
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    self browser ifNil: [^NewSystemBrowser browseClass:class].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    (UserPreferences current alwaysOpenNewTabWhenCtrlClick 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        or:[self browser navigationState modified])  
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
            [self browser 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
                spawnFullBrowserInClass: class selector:nil in:#newBuffer]
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        ifFalse:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
            [self browser 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                switchToClass: class]
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "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
   110
    "Modified: / 25-07-2010 / 11:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
browser
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    ^codeView browserHolder value
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    "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
   118
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
!CodeNavigationService methodsFor:'event handling'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
button1Press
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    codeView syntaxElementSelection ifNil:[^self].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    codeView syntaxElementSelection type == #selector ifTrue:[^self button1PressForSelector: codeView syntaxElementSelection value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    codeView syntaxElementSelection type == #class    ifTrue:[^self browseClass:codeView syntaxElementSelection value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "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
   130
    "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
   131
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
button1PressForSelector: selector
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    | impls menu |
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   136
    impls := codeView implementorsOf: selector.
10271
44c51d135362 changed: #button1PressForSelector: bug fix
vrany
parents: 10254
diff changeset
   137
    impls size = 1 ifTrue:[^codeView browseMethod: impls anyOne].
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   138
    menu := codeView implementorsMenu: impls selector: selector.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    menu showAtPointer.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    "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
   143
    "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
   144
    "Modified: / 07-07-2011 / 17:16:23 / jv"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
button2Press
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    | sel |
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    sel := codeView syntaxElementSelection.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    (sel notNil and:[sel type == #selector]) ifTrue:[^self button2PressForSelector: sel value].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "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
   154
    "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
   155
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
button2PressForSelector: selector
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    | senders menu |
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   160
    senders := codeView implementorsOf: selector.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    senders size = 1 ifTrue:[^self browseMethod: senders anyOne].
10254
43001ebe1490 Merged with JV's branch
vrany
parents: 10076
diff changeset
   162
    menu := codeView sendersMenu: senders selector: selector.
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    menu showAtPointer.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "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
   167
    "Modified: / 30-06-2011 / 19:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
buttonMotion: button x:x y:y in: view
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    (view == textView and:[textView sensor ctrlDown]) ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        [self highlightElementAtX:x y:y. ^true].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    ^false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    "Created: / 06-03-2010 / 20:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
buttonPress: button x:x y:y in: view
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    (view == textView) ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        [codeView sensor ctrlDown ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
            [button == 1      ifTrue: [self button1Press.^true].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
            button == #paste ifTrue: [self button2Press.^true].   
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
            button == 2      ifTrue: [self button2Press.^true]].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        button == 1 ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            self highlightVariableAtX:x y:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
        ]
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
        ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    ^false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    "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
   201
    "Modified: / 25-06-2010 / 14:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
keyPress:key x:x y:y in:view 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    (view == textView) ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        (key == #'Control_L' or:[ key == #Ctrl ]) ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
            self highlightElementAtX:x y:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
            ^ true
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
        self highlightVariableAtCursor.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        ^ false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    ^ false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    "Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "Modified: / 25-06-2010 / 14:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
keyRelease: key x:x y:y in: view
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    "Handles an event in given view (a subview of codeView).
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
     If the method returns true, the event will not be processed
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
     by the view."
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
        [self highlightClear. textView redraw. ^true].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    ^false
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    "Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
!CodeNavigationService methodsFor:'initialization'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
initialize
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    super initialize.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    selectorEmphasis := self class defaultSelectorEmphasis.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    variableEmphasis := self class defaultVariableEmphasis.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "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
   245
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
!CodeNavigationService methodsFor:'private'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
elementAtCursor
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    ^self elementAtLine: textView cursorLine col: textView cursorCol - 1
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    "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
   253
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
elementAtLine:line col:col 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    |characterPosition index element |
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    characterPosition := textView characterPositionOfLine:line col:col.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    index > (codeView syntaxElements) size ifTrue:[^nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    element := (codeView syntaxElements) at: index.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    (characterPosition between: element start and: element stop) ifFalse:[^nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ^element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
elementAtX:x y:y 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    |visibleLine line col|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    codeView syntaxElements ifNil:[^nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    visibleLine := textView visibleLineOfY:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    col := textView colOfX:x inVisibleLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    line := textView visibleLineToAbsoluteLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    ^self elementAtLine:line col:col
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    "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
   278
    "Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
highlighEmphasisFor: element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    element ifNil:[^nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    element type == #selector ifTrue:[^selectorEmphasis].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    element type == #variable ifTrue:[^variableEmphasis].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    ^nil
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
highlightClear
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    |textView|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    codeView syntaxElementSelection == nil ifTrue:[^ self].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    textView := codeView textView.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    textView list ifNil:[ ^ self ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    textView list do:[:line | 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
        line isText ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
            line emphasisAllRemove: currentEmphasis
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
        ]
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    textView redraw.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    codeView syntaxElementSelection:nil.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    "Modified: / 26-12-2007 / 12:28:05 / janfrog"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    "Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "Modified: / 30-06-2011 / 11:07:05 / cg"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
highlightElement: element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    codeView syntaxElementSelection == element ifTrue:[^ self].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    currentEmphasis := self highlighEmphasisFor: element.         
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    element 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
       ifNotNil:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
            [|e|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
            codeView syntaxElementSelection: element.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
            e := element.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
            [e isNil] whileFalse:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
                [self highlightWithoutClearFrom: e start to: e stop.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
                e := e next].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
            e := element prev.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
            [e isNil] whileFalse:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
                [self highlightWithoutClearFrom: e start to: e stop.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
                e := e prev]].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    textView invalidate
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: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    "Modified: / 25-06-2010 / 14:18:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
    "Modified: / 30-06-2011 / 11:06:42 / cg"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
highlightElementAtCursor
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    self highlightElementAtLine: textView cursorLine col: textView cursorCol
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: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    "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
   342
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
highlightElementAtLine:line col:col 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
    |characterPosition index element |
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    characterPosition := textView characterPositionOfLine:line col:col.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    index := SortedCollection binarySearch: (codeView syntaxElements) forIndexOf: characterPosition.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    index > (codeView syntaxElements) size ifTrue:[^self highlightElement: nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    element := (codeView syntaxElements) at: index.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    (characterPosition between: element start and: element stop) ifFalse:[^self highlightElement: nil].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    self highlightElement:element
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    "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
   356
    "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
   357
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
highlightElementAtX:x y:y 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    |visibleLine line col|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    codeView syntaxElements ifNil:[^self].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    visibleLine := textView visibleLineOfY:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
    col := textView colOfX:x inVisibleLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    line := textView visibleLineToAbsoluteLine:visibleLine.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    self highlightElementAtLine:line col:col
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    "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
   369
    "Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    |line start end|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    (lineNo between:startLine and:endLine) ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        ^ self
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    line := textView listAt:lineNo.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    start := lineNo = startLine ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
                startCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
            ] ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
                line indexOfNonSeparator
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
            ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    end := lineNo = endLine ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
                endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
            ] ifFalse:[ line size ].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    line 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
        emphasisFrom:start
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
        to:end
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
        add: currentEmphasis
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    "Modified: / 03-09-2010 / 22:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
highlightVariable:e 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    (e notNil and:[ e type == #variable ]) ifTrue:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
        self highlightElement:e.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    ] ifFalse:[
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
        self highlightClear.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    ]
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
highlightVariableAtCursor
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    |e|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    e := self elementAtCursor.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
    self highlightVariable: e
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
    "Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
highlightVariableAtX:x y:y 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    |e|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    e := self elementAtX:x y:y.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    self highlightVariable:e.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    "Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
highlightWithoutClearFrom: start to: end
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    "Remove underlined emphasis"
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    |startLine startCol endLine endCol|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    startLine := textView lineOfCharacterPosition:start.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    startCol := start - (textView characterPositionOfLine:startLine col:1) + 1.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
    endLine := textView lineOfCharacterPosition:end.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
    endCol := end - (textView characterPositionOfLine:endLine col:1) + 1.
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
    "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
   434
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol 
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
    textView list keysAndValuesDo:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
        [:lineNo :line|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
        |start end|
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
        line isText ifTrue:
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
            [self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]].
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
    "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
   445
! !
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
!CodeNavigationService class methodsFor:'documentation'!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
version_CVS
10271
44c51d135362 changed: #button1PressForSelector: bug fix
vrany
parents: 10254
diff changeset
   450
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.4 2011-07-07 16:17:21 vrany Exp $'
9979
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
!
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
version_SVN
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    ^ '§Id: Tools__CodeNavigationService.st 7788 2011-06-17 07:57:48Z vranyj1 §'
00b306851c88 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
! !