Tools__CodeCompletionMenu.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Jul 2011 15:21:34 +0200
changeset 9986 234457682730
parent 9959 9ed584296d79
child 10078 3bd0f45a96d2
permissions -rw-r--r--
initial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ NameSpace: Tools }"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
SelectionInListModelView subclass:#CodeCompletionMenu
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'wholeList typedString codeView selectedString cursorCol column
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
		position'
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'Interface-CodeView'
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!CodeCompletionMenu class methodsFor:'documentation'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 2006 by eXept Software AG
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
	      All Rights Reserved
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 This software is furnished under a license and may be used
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 only in accordance with the terms of that license and with the
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 be provided or otherwise made available to, or used by, any
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 other person.  No title to or ownership of the software is
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 hereby transferred.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
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:'interface opening'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
openFor: aCodeView at: anInteger with:aCollection
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    |m|
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    m := (self new)
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        initializeForView:aCodeView at: anInteger with: aCollection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    ^ m openModalXX.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    "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
    51
    "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
    52
    "Modified: / 01-07-2011 / 00:05:01 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!CodeCompletionMenu methodsFor:'accessing'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
contentHeight
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    | size |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    size := self list size max: 10.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    ^(size * (wholeList anyOne heightOn:self)) + 15
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "Created: / 22-03-2006 / 22:36:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "Modified: / 26-03-2006 / 19:39:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "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
    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
contentWidth
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    | w |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    w := wholeList
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        inject:0
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        into:[:max :each|max max:(each widthOn:self)].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    ^(w + 20) min: 600
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "Created: / 22-03-2006 / 22:36:49 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "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
    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:'event handling'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
backspaceKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    typedString isEmpty ifTrue:[^self topView close].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    typedString := typedString allButLast.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    self updateList
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: / 25-05-2005 / 20:03:22 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "Modified: / 22-03-2006 / 21:04:09 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
characterKeyPress:aCharacter
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    | newString |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    newString := typedString , aCharacter.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    (wholeList anySatisfy:[:s|s startsWith:newString]) ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        typedString := newString.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        self updateList.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "Created: / 25-05-2005 / 20:02:12 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    "Modified: / 27-05-2005 / 22:29:10 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
doubleClicked
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    self returnKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "Created: / 30-06-2011 / 20:01:03 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
keyPress:key x:x y:y
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    key isCharacter ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        self characterKeyPress:key.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        codeView keyPress:key x:x y:y.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    key == #Return ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
        self returnKeyPress.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    key == #BackSpace ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        codeView keyPress:key x:x y:y.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        self backspaceKeyPress.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        ^self
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    key == #Tab ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
           "/self tabKeyPressX:x y:y.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
           Transcript showCR:'Tab-completion broken. Disabled'.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
           ^self.
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
    ^super keyPress:key x:x y:y
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "Created: / 25-05-2005 / 19:57:27 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    "Modified: / 22-03-2006 / 21:12:35 / janfrog"
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
mapped
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    super mapped.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    self forceUngrabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    self grabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
"/    self requestFocus.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
"/    self grabPointer.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
"/    self grabKeyboard.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "Created: / 30-06-2011 / 19:58:59 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
returnKeyPress
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    self list size = 1 ifTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
        selectedString := self list first.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
        codeView setCursorCol:cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        self topView close
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    ] ifFalse:[        
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        self selection ifNotNil:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
            selectedString := self at:self selection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
            codeView setCursorCol:cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
            self topView close
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
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "Created: / 25-05-2005 / 20:34:16 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    "Modified: / 29-05-2005 / 09:40:15 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
tabKeyPressX:x y:y
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    | currentList idx char completionString|
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    currentList := self list.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    idx := typedString size + 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    [
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        (currentList allSatisfy:[:s|s size >= idx]) and:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
            char := currentList anyOne at:idx.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
            currentList allSatisfy:[:s|(s at:idx) == char]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
        ]
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    ] whileTrue:[
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
        idx := idx + 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    ].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    completionString := currentList anyOne copyFrom:(typedString size + 1) to:idx - 1.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    completionString do:[:c|codeView keyPress:c x:x y:y].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    typedString := typedString , completionString.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    Transcript showCR:typedString
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "Created: / 29-05-2005 / 09:50:03 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
!CodeCompletionMenu methodsFor:'initialize'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
initialize
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    super initialize.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    typedString := ''.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    highlightMode := #line
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "Created: / 28-05-2005 / 19:49:09 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
initializeForView: aTextView at: anInteger with: aCollection 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    self initialize.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    codeView := aTextView.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    wholeList := aCollection.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "/ self font:codeView font.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    position := anInteger.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    cursorCol := codeView cursorCol.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "Modified: / 29-05-2005 / 09:39:35 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "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
   218
    "Modified: / 01-07-2011 / 00:08:31 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!CodeCompletionMenu methodsFor:'interface opening'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
openModalXX
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    | modalBox p |
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    self updateList.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    self list size == 1 ifTrue:[^self list anyOne string copyFrom:(typedString size + 1)].
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    modalBox := PopUpView new.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ScrollableView   
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
        forView:self 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        hasHorizontalScrollBar:false 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        hasVerticalScrollBar:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
        miniScrollerH:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
        miniScrollerV:true 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
        origin:0.0@0.0 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
        corner:1.0@1.0 
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
        in:modalBox.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    modalBox extent:(self contentWidth) @ (self contentHeight).
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    p := codeView originRelativeTo: nil.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    p x: (p x + (codeView xOfPosition:position) - textStartLeft - 3).
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    p y: (p y + ("(codeView yOfPosition:position) max:"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
                    (codeView yOfCursor)) + font maxHeight).
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    "/x := codeView absoluteXOfCursor - (typedString widthOn:codeView) - 10 - 12"/width of icon
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    " 10 - Magic number, but looks good on my computer"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "/x := (codeView absoluteXOfPosition: position) - textStartLeft - 3.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "/y := codeView absoluteYOfCursor + font maxHeight.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    "/y := (codeView absoluteYOfCursor max: (codeView absoluteYOfPosition: position))  + font maxHeight.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    modalBox origin:p.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    modalBox makeFullyVisible.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    modalBox exclusivePointer:false.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    modalBox open.
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ^ selectedString ifNotNil:[selectedString 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
    "Modified: / 01-07-2011 / 09:30:29 / cg"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
!CodeCompletionMenu methodsFor:'updating'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
updateList
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    self list:(wholeList select:[:s| s startsWith:typedString])
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    "Created: / 25-05-2005 / 20:06:07 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    "Modified: / 27-05-2005 / 22:23:37 / janfrog"
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
! !
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
!CodeCompletionMenu class methodsFor:'documentation'!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
version_CVS
9986
234457682730 initial checkin
Claus Gittinger <cg@exept.de>
parents: 9959
diff changeset
   276
    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeCompletionMenu.st,v 1.2 2011-07-01 13:21:34 cg Exp $'
9959
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
!
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
version_SVN
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    ^ '§Id: Tools__CodeCompletionMenu.st 7690 2011-03-19 02:23:25Z vranyj1 §'
9ed584296d79 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
! !