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