Tools__CodeCompletionMenu.st
author Claus Gittinger <cg@exept.de>
Wed, 05 Jun 2019 14:16:59 +0200
changeset 18805 f6df57c6dbfb
parent 18187 154e5460cf12
child 19144 5133e7763456
permissions -rw-r--r--
#BUGFIX by cg class: AbstractFileBrowser changed: #currentFileNameHolder endless loop if file not present.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18187
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
     1
"{ Encoding: utf8 }"
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
     2
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
10078
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
     4
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
     5
              All Rights Reserved
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
10078
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
     7
Permission is hereby granted, free of charge, to any person
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
     8
obtaining a copy of this software and associated documentation
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
     9
files (the 'Software'), to deal in the Software without
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    10
restriction, including without limitation the rights to use,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    11
copy, modify, merge, publish, distribute, sublicense, and/or sell
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    12
copies of the Software, and to permit persons to whom the
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    13
Software is furnished to do so, subject to the following
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    14
conditions:
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    15
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    16
The above copyright notice and this permission notice shall be
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    17
included in all copies or substantial portions of the Software.
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    18
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    19
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    20
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    21
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    22
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    23
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    24
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    25
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    26
OTHER DEALINGS IN THE SOFTWARE.
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"{ Package: 'stx:libtool' }"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
"{ NameSpace: Tools }"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
SelectionInListModelView subclass:#CodeCompletionMenu
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	instanceVariableNames:'wholeList typedString codeView selectedString cursorCol column
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
		position'
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
	classVariableNames:''
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
	poolDictionaries:''
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
	category:'Interface-CodeView'
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!CodeCompletionMenu class methodsFor:'documentation'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
copyright
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
10078
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    44
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    45
              All Rights Reserved
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    46
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    47
Permission is hereby granted, free of charge, to any person
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    48
obtaining a copy of this software and associated documentation
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    49
files (the 'Software'), to deal in the Software without
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    50
restriction, including without limitation the rights to use,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    51
copy, modify, merge, publish, distribute, sublicense, and/or sell
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    52
copies of the Software, and to permit persons to whom the
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    53
Software is furnished to do so, subject to the following
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    54
conditions:
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
10078
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    56
The above copyright notice and this permission notice shall be
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    57
included in all copies or substantial portions of the Software.
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    58
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    59
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    60
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    61
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    62
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    63
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    64
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    65
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3bd0f45a96d2 changed: #copyright
Claus Gittinger <cg@exept.de>
parents: 9986
diff changeset
    66
OTHER DEALINGS IN THE SOFTWARE.
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
!CodeCompletionMenu class methodsFor:'interface opening'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
openFor: aCodeView at: anInteger with:aCollection
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    |m|
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    m := (self new)
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        initializeForView:aCodeView at: anInteger with: aCollection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    ^ m openModalXX.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "Created: / 16-02-2010 / 10:18:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "Modified: / 04-09-2010 / 08:41:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    "Modified: / 01-07-2011 / 00:05:01 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!CodeCompletionMenu methodsFor:'accessing'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
contentHeight
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    | size |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    size := self list size max: 10.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    ^(size * (wholeList anyOne heightOn:self)) + 15
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    "Created: / 22-03-2006 / 22:36:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    "Modified: / 26-03-2006 / 19:39:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "Modified: / 16-02-2010 / 10:58:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
contentWidth
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    | w |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    w := wholeList
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
        inject:0
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        into:[:max :each|max max:(each widthOn:self)].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    ^(w + 20) min: 600
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "Created: / 22-03-2006 / 22:36:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "Modified: / 06-03-2010 / 08:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!CodeCompletionMenu methodsFor:'event handling'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
backspaceKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    typedString isEmpty ifTrue:[^self topView close].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    typedString := typedString allButLast.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    self updateList
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "Created: / 25-05-2005 / 20:03:22 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    "Modified: / 22-03-2006 / 21:04:09 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
characterKeyPress:aCharacter
12107
9aa2298d243a class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 10078
diff changeset
   127
    | newString |
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    newString := typedString , aCharacter.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    (wholeList anySatisfy:[:s|s startsWith:newString]) ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        typedString := newString.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
        self updateList.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    "Created: / 25-05-2005 / 20:02:12 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    "Modified: / 27-05-2005 / 22:29:10 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
doubleClicked
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    self returnKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    "Created: / 30-06-2011 / 20:01:03 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
keyPress:key x:x y:y
12107
9aa2298d243a class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 10078
diff changeset
   146
    <resource: #keyboard (#Return #BackSpace #Tab)>
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    key isCharacter ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
        self characterKeyPress:key.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        codeView keyPress:key x:x y:y.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    key == #Return ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
        self returnKeyPress.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    key == #BackSpace ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
        codeView keyPress:key x:x y:y.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
        self backspaceKeyPress.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    key == #Tab ifTrue:[
18187
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   163
       "/self tabKeyPressX:x y:y.
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   164
       Transcript showCR:'Tab-completion broken. Disabled'.
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   165
       ^self.
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    ^super keyPress:key x:x y:y
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    "Created: / 25-05-2005 / 19:57:27 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    "Modified: / 22-03-2006 / 21:12:35 / janfrog"
18187
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   172
    "Modified (format): / 09-06-2018 / 09:30:34 / Claus Gittinger"
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
mapped
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    super mapped.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    self forceUngrabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    self grabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
"/    self requestFocus.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
"/    self grabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
"/    self grabKeyboard.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    "Created: / 30-06-2011 / 19:58:59 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
returnKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    self list size = 1 ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        selectedString := self list first.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        codeView setCursorCol:cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        self topView close
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    ] ifFalse:[        
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        self selection ifNotNil:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            selectedString := self at:self selection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
            codeView setCursorCol:cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
            self topView close
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
        ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "Created: / 25-05-2005 / 20:34:16 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    "Modified: / 29-05-2005 / 09:40:15 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
tabKeyPressX:x y:y
12107
9aa2298d243a class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 10078
diff changeset
   206
    | currentList idx char completionString|
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    currentList := self list.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    idx := typedString size + 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    [
13514
b94a5e518918 class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 12107
diff changeset
   211
        (currentList conform:[:s|s size >= idx]) 
b94a5e518918 class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 12107
diff changeset
   212
        and:[
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
            char := currentList anyOne at:idx.
13514
b94a5e518918 class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 12107
diff changeset
   214
            currentList conform:[:s|(s at:idx) == char]
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    ] whileTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
        idx := idx + 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    completionString := currentList anyOne copyFrom:(typedString size + 1) to:idx - 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    completionString do:[:c|codeView keyPress:c x:x y:y].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    typedString := typedString , completionString.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    Transcript showCR:typedString
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    "Created: / 29-05-2005 / 09:50:03 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
!CodeCompletionMenu methodsFor:'initialize'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
initialize
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    super initialize.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    typedString := ''.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    highlightMode := #line
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "Created: / 28-05-2005 / 19:49:09 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
initializeForView: aTextView at: anInteger with: aCollection 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    self initialize.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    codeView := aTextView.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    wholeList := aCollection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    "/ self font:codeView font.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    position := anInteger.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    cursorCol := codeView cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "Modified: / 29-05-2005 / 09:39:35 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "Created: / 16-02-2010 / 10:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "Modified: / 01-07-2011 / 00:08:31 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
!CodeCompletionMenu methodsFor:'interface opening'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
openModalXX
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    | modalBox p |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    self updateList.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    self list size == 1 ifTrue:[^self list anyOne string copyFrom:(typedString size + 1)].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    modalBox := PopUpView new.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    ScrollableView   
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
        forView:self 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
        hasHorizontalScrollBar:false 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
        hasVerticalScrollBar:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
        miniScrollerH:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
        miniScrollerV:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
        origin:0.0@0.0 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        corner:1.0@1.0 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
        in:modalBox.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    modalBox extent:(self contentWidth) @ (self contentHeight).
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    p := codeView originRelativeTo: nil.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    p x: (p x + (codeView xOfPosition:position) - textStartLeft - 3).
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    p y: (p y + ("(codeView yOfPosition:position) max:"
13961
8139baad1f4e class: Tools::CodeCompletionMenu
Stefan Vogel <sv@exept.de>
parents: 13514
diff changeset
   280
                    (codeView yOfCursor)) + gc font maxHeight).
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    "/x := codeView absoluteXOfCursor - (typedString widthOn:codeView) - 10 - 12"/width of icon
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    " 10 - Magic number, but looks good on my computer"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "/x := (codeView absoluteXOfPosition: position) - textStartLeft - 3.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    "/y := codeView absoluteYOfCursor + font maxHeight.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    "/y := (codeView absoluteYOfCursor max: (codeView absoluteYOfPosition: position))  + font maxHeight.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    modalBox origin:p.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    modalBox makeFullyVisible.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    modalBox exclusivePointer:false.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    modalBox open.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    ^ selectedString ifNotNil:[selectedString string copyFrom:(typedString size + 1)]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "Modified: / 01-07-2011 / 09:30:29 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
!CodeCompletionMenu methodsFor:'updating'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
updateList
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    self list:(wholeList select:[:s| s startsWith:typedString])
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "Created: / 25-05-2005 / 20:06:07 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    "Modified: / 27-05-2005 / 22:23:37 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
!CodeCompletionMenu class methodsFor:'documentation'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
version_CVS
18187
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   309
    ^ '$Header$'
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
version_SVN
18187
154e5460cf12 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 13961
diff changeset
   313
    ^ '$Id$'
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
! !
12107
9aa2298d243a class: Tools::CodeCompletionMenu
Claus Gittinger <cg@exept.de>
parents: 10078
diff changeset
   315