author | Claus Gittinger <cg@exept.de> |
Mon, 15 Jul 2019 15:33:58 +0200 | |
branch | cvs_MAIN |
changeset 1091 | 8c18b8f6ff0c |
parent 1079 | 408cfc9ef1b1 |
child 1092 | d8d8bc8c6b00 |
permissions | -rw-r--r-- |
1079 | 1 |
"{ Encoding: utf8 }" |
2 |
||
252
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
3 |
" |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
4 |
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
5 |
Copyright (C) 2013-2014 Jan Vrany |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
6 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
7 |
This library is free software; you can redistribute it and/or |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
8 |
modify it under the terms of the GNU Lesser General Public |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
9 |
License as published by the Free Software Foundation; either |
917 | 10 |
version 2.1 of the License. |
252
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
11 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
12 |
This library is distributed in the hope that it will be useful, |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
15 |
Lesser General Public License for more details. |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
16 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
17 |
You should have received a copy of the GNU Lesser General Public |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
18 |
License along with this library; if not, write to the Free Software |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
20 |
" |
249
8bc64027b189
Package renamed to stx:goodies/smallsense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
245
diff
changeset
|
21 |
"{ Package: 'stx:goodies/smallsense' }" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
"{ NameSpace: SmallSense }" |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
EditTextViewCompletionSupport subclass:#CompletionController |
154
b96fbde91144
Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
153
diff
changeset
|
26 |
instanceVariableNames:'support seqno completeIfUnambiguous' |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
classVariableNames:'' |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
poolDictionaries:'' |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
29 |
category:'SmallSense-Core' |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
30 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
31 |
|
252
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
32 |
!CompletionController class methodsFor:'documentation'! |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
33 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
34 |
copyright |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
35 |
" |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
36 |
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
37 |
Copyright (C) 2013-2014 Jan Vrany |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
38 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
39 |
This library is free software; you can redistribute it and/or |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
40 |
modify it under the terms of the GNU Lesser General Public |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
41 |
License as published by the Free Software Foundation; either |
917 | 42 |
version 2.1 of the License. |
252
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
43 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
44 |
This library is distributed in the hope that it will be useful, |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
45 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
46 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
47 |
Lesser General Public License for more details. |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
48 |
|
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
49 |
You should have received a copy of the GNU Lesser General Public |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
50 |
License along with this library; if not, write to the Free Software |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
51 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
52 |
" |
feba6ee5c814
Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
249
diff
changeset
|
53 |
! ! |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
54 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
55 |
!CompletionController class methodsFor:'instance creation'! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
56 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
57 |
new |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
58 |
"return an initialized instance" |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
59 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
60 |
^ self basicNew initialize. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
61 |
! ! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
62 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
63 |
!CompletionController methodsFor:'accessing'! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
64 |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
65 |
completionEngine |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
66 |
| engineClass | |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
67 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
68 |
engineClass := self completionEngineClass. |
917 | 69 |
^ engineClass notNil |
70 |
ifTrue:[ engineClass new ] |
|
71 |
ifFalse:[ nil ]. |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
72 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
73 |
"Created: / 18-05-2014 / 11:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
74 |
! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
75 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
76 |
environment |
917 | 77 |
^ support notNil |
78 |
ifTrue:[support environment] |
|
79 |
ifFalse:[Smalltalk]. |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
80 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
81 |
"Created: / 18-05-2014 / 11:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
82 |
! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
83 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
84 |
support |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
85 |
^ support |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
86 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
87 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
88 |
support:anEditSupport |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
89 |
support := anEditSupport. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
90 |
! ! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
91 |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
92 |
!CompletionController methodsFor:'accessing-classes'! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
93 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
94 |
completionEngineClass |
917 | 95 |
^ support notNil |
96 |
ifTrue:[ support completionEngineClass ] |
|
97 |
ifFalse:[ nil ]. |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
98 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
99 |
"Created: / 18-05-2014 / 11:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
100 |
! ! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
101 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
102 |
!CompletionController methodsFor:'events'! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
103 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
104 |
handleKeyPress:key x:x y:y |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
105 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
106 |
key == #Control_L ifTrue:[ |
1051 | 107 |
completionView notNil ifTrue:[ |
108 |
^ false. |
|
109 |
]. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
110 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
111 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
112 |
key == #CodeCompletion ifTrue: [ |
1051 | 113 |
autoSelect := true. |
114 |
self startCompletionProcess. |
|
115 |
^ true |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
116 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
117 |
|
1051 | 118 |
editView cursorCol <= 1 ifTrue:[^ false]. |
119 |
||
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
120 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
1051 | 121 |
| c | |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
122 |
|
1051 | 123 |
c := editView characterBeforeCursor. |
124 |
(c notNil and:[c isAlphaNumeric]) ifTrue:[ |
|
125 |
^ false |
|
126 |
]. |
|
917 | 127 |
]. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
128 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
129 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
130 |
completionView notNil ifTrue:[ |
1051 | 131 |
(key == #Return and:[completionView hasSelection]) ifTrue:[ |
132 |
self complete. |
|
133 |
^ true. |
|
134 |
]. |
|
135 |
key == #Tab ifTrue:[ |
|
136 |
self handleKeyPressTab. |
|
137 |
^ true |
|
138 |
]. |
|
139 |
key isCharacter ifTrue:[ |
|
140 |
(self updateSelectionAfterKeyPress: key) ifTrue:[ |
|
141 |
^ true |
|
142 |
]. |
|
143 |
]. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
144 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
145 |
^ super handleKeyPress:key x:x y:y |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
146 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
147 |
"Created: / 27-09-2013 / 15:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
241
174331ea79a5
Oops, fix for previous commit: avoid duplicate characters inserted when completion is unambiguous.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
239
diff
changeset
|
148 |
"Modified: / 18-06-2014 / 10:17:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1051 | 149 |
"Modified: / 24-08-2017 / 21:33:39 / cg" |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
150 |
! |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
151 |
|
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
152 |
handleKeyPressTab |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
153 |
"Tab has been pressed, try to complete longest common prefix" |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
154 |
|
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
155 |
| first prefix matching longest minlen | |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
156 |
|
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
157 |
first := completionView list first. |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
158 |
prefix := self prefixAlreadyWritten. |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
159 |
matching := OrderedCollection new. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
160 |
minlen := SmallInteger maxVal. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
161 |
completionView list do:[:po | |
917 | 162 |
| s | |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
163 |
|
917 | 164 |
s := po stringToComplete. |
165 |
(s startsWith: prefix) ifTrue:[ |
|
166 |
matching add: po -> s. |
|
167 |
minlen := minlen min: s size. |
|
168 |
]. |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
169 |
]. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
170 |
matching isEmpty ifTrue:[ |
917 | 171 |
completionView flash. |
172 |
^self. |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
173 |
]. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
174 |
matching size == 1 ifTrue:[ |
917 | 175 |
self complete: matching first key. |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
176 |
]. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
177 |
|
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
178 |
longest := String streamContents:[:s | |
917 | 179 |
| i | |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
180 |
|
917 | 181 |
s nextPutAll: prefix. |
182 |
i := prefix size + 1. |
|
183 |
[ i <= minlen ] whileTrue:[ |
|
184 |
| c | |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
185 |
|
917 | 186 |
c := matching first value at: i. |
187 |
(matching allSatisfy:[:e|(e value at: i) == c]) ifTrue:[ |
|
188 |
s nextPut:c. |
|
189 |
i := i + 1. |
|
190 |
] ifFalse:[ |
|
191 |
"/ terminate the loop |
|
192 |
i := minlen + 2. |
|
193 |
] |
|
194 |
] |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
195 |
]. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
196 |
longest size = prefix size ifTrue:[ |
917 | 197 |
completionView flash. |
198 |
^self. |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
199 |
]. |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
200 |
editView insertStringAtCursor:(longest copyFrom: prefix size + 1). |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
201 |
|
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
202 |
"Created: / 31-03-2014 / 22:55:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
203 |
"Modified: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
204 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
205 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
206 |
postKeyPress:key |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
207 |
seqno := seqno + 1. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
208 |
seqno == SmallInteger maxVal ifTrue:[ |
917 | 209 |
seqno := 0. |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
210 |
]. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
211 |
|
917 | 212 |
(UserPreferences current immediateCodeCompletion == true) ifFalse:[ |
213 |
"/ only update, if already open |
|
214 |
completionView isNil ifTrue:[^ self]. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
215 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
216 |
|
198
a199868d1eab
Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
217 |
"/ (key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
a199868d1eab
Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
218 |
"/ self closeCompletionView. |
a199868d1eab
Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
219 |
"/ ^ self |
a199868d1eab
Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
192
diff
changeset
|
220 |
"/ ]. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
221 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
222 |
key isCharacter ifTrue:[ |
917 | 223 |
key isLetterOrDigit not ifTrue:[ |
224 |
"/ Hack for Java - should be delegated to completion engine |
|
225 |
(key == $. and:[support notNil and:[ support language isJavaLike ]]) ifTrue:[ |
|
226 |
^ self |
|
227 |
]. |
|
228 |
self closeCompletionView |
|
229 |
] ifFalse:[ |
|
230 |
| c | |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
231 |
|
917 | 232 |
c := editView characterBeforeCursor. |
233 |
(c notNil and:[c isLetterOrDigit]) ifTrue:[ |
|
234 |
c := editView characterUnderCursor. |
|
235 |
c isSeparator ifTrue:[ |
|
236 |
autoSelect := false. |
|
237 |
self updateCompletionList. |
|
238 |
]. |
|
239 |
] |
|
240 |
]. |
|
241 |
^ self |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
242 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
243 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
244 |
"Created: / 28-09-2013 / 00:21:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
245 |
"Modified: / 18-05-2014 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
246 |
! ! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
247 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
248 |
!CompletionController methodsFor:'initialization'! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
249 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
250 |
initialize |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
251 |
"Invoked when a new instance is created." |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
252 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
253 |
"/ please change as required (and remove this comment) |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
254 |
"/ support := nil. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
255 |
seqno := 0. |
917 | 256 |
completeIfUnambiguous := (UserPreferences current smallSenseCompleteIfUnambiguous == true). |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
257 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
258 |
"/ super initialize. -- commented since inherited method does nothing |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
259 |
|
154
b96fbde91144
Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
153
diff
changeset
|
260 |
"Modified: / 18-01-2014 / 23:10:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
261 |
! ! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
262 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
263 |
!CompletionController methodsFor:'private'! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
264 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
265 |
complete |
1079 | 266 |
editView shown ifFalse:[ |
267 |
self closeCompletionView. |
|
268 |
^ self. |
|
269 |
]. |
|
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
270 |
self complete: completionView selection. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
271 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
272 |
"Created: / 27-09-2013 / 15:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
273 |
"Modified: / 31-03-2014 / 23:22:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1079 | 274 |
"Modified: / 12-01-2019 / 13:25:35 / Claus Gittinger" |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
275 |
! |
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
276 |
|
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
277 |
complete: item |
274
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
278 |
^ self complete: item afterKeyPress: nil |
185
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
279 |
|
75738108cc3f
Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
280 |
"Created: / 31-03-2014 / 23:21:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
274
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
281 |
"Modified: / 11-08-2014 / 14:53:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
282 |
! |
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
283 |
|
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
284 |
complete: item afterKeyPress: keyOrNil |
285
a5640bc14376
Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
283
diff
changeset
|
285 |
self closeCompletionView. |
a5640bc14376
Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
283
diff
changeset
|
286 |
item insert. |
917 | 287 |
keyOrNil notNil ifTrue:[ |
288 |
support keyPressIgnored. |
|
285
a5640bc14376
Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
283
diff
changeset
|
289 |
]. |
274
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
290 |
|
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
291 |
"Created: / 11-08-2014 / 14:53:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
292 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
293 |
|
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
294 |
prefixAlreadyWritten |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
295 |
| list first | |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
296 |
|
917 | 297 |
completionView notNil ifTrue:[ |
298 |
list := completionView list. |
|
299 |
list notEmptyOrNil ifTrue:[ |
|
300 |
first := list first. |
|
301 |
(completionView list allSatisfy:[:e | e class == first class ]) ifTrue:[ |
|
302 |
^ first stringAlreadyWritten |
|
303 |
] |
|
304 |
] |
|
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
305 |
]. |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
306 |
^ support wordBeforeCursor string . |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
307 |
|
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
308 |
"Created: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
245
172822a63cff
Fix in CompletionController>>prefixAlreadyWritten - let the first PO answer the prefix written...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
241
diff
changeset
|
309 |
"Modified: / 24-06-2014 / 11:40:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
310 |
! |
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
311 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
312 |
stopCompletionProcess |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
313 |
"kill any background completion process" |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
314 |
|
917 | 315 |
editView sensor flushUserEventsFor: self. |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
316 |
super stopCompletionProcess |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
317 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
318 |
"Created: / 02-10-2013 / 15:09:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
319 |
"Modified: / 03-10-2013 / 11:03:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
320 |
! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
321 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
322 |
updateCompletionList |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
323 |
"called for keypress events" |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
324 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
325 |
completionView isNil ifTrue:[ |
917 | 326 |
super updateCompletionList |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
327 |
] ifFalse:[ |
917 | 328 |
self updateSelection. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
329 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
330 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
331 |
"Created: / 27-09-2013 / 15:58:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
332 |
"Modified: / 28-09-2013 / 00:15:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
333 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
334 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
335 |
updateSelection |
917 | 336 |
"Updates selection in completion view based on currently typed partial |
239
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
337 |
text. Return true if the complection window should be closed or false |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
338 |
if it shall be kept open. " |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
339 |
|
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
340 |
^ self updateSelectionAfterKeyPress: nil |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
341 |
|
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
342 |
"Created: / 27-09-2013 / 16:16:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
343 |
"Modified (comment): / 17-06-2014 / 07:24:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
344 |
! |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
345 |
|
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
346 |
updateSelectionAfterKeyPress: keyOrNil |
917 | 347 |
"Updates selection in completion view based on currently typed partial |
239
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
348 |
text. Return true if the complection window should be closed or false |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
349 |
if it shall be kept open. |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
350 |
|
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
351 |
If `keyOrNil` is not nil, then it's a key press that triggered the update |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
352 |
which HAS NOT YET been processed by a `editView`. |
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
353 |
" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
354 |
|
192
f27ce6dac101
Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
189
diff
changeset
|
355 |
| list prefix matcher1 matches1 matcher2 matches2 | |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
356 |
|
189
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
357 |
list := completionView list. |
192
f27ce6dac101
Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
189
diff
changeset
|
358 |
matcher1 := CompletionEngine exactMatcher. |
f27ce6dac101
Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
189
diff
changeset
|
359 |
matcher2 := CompletionEngine inexactMatcher. |
221
5590362d7223
Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
218
diff
changeset
|
360 |
prefix := self prefixAlreadyWritten. |
917 | 361 |
keyOrNil isCharacter ifTrue:[ |
362 |
prefix := prefix , keyOrNil |
|
239
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
363 |
]. |
192
f27ce6dac101
Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
189
diff
changeset
|
364 |
matches1 := list select:[:po | matcher1 value: prefix value: po stringToComplete ]. |
189
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
365 |
matches1 notEmptyOrNil ifTrue:[ |
917 | 366 |
matches1 size == 1 ifTrue:[ |
367 |
| selection | |
|
274
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
368 |
|
917 | 369 |
selection := matches1 anElement. |
370 |
(completeIfUnambiguous and: [(editView sensor hasKeyEventFor:editView) not]) ifTrue:[ |
|
371 |
self complete: selection afterKeyPress: keyOrNil. |
|
372 |
^ true |
|
373 |
] ifFalse:[ |
|
374 |
completionView selection: selection |
|
375 |
]. |
|
376 |
] ifFalse:[ |
|
377 |
| selection | |
|
154
b96fbde91144
Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
153
diff
changeset
|
378 |
|
917 | 379 |
selection := matches1 inject: matches1 anElement into:[:mostrelevant :each | |
380 |
each relevance > mostrelevant relevance |
|
381 |
ifTrue:[each] |
|
382 |
ifFalse:[mostrelevant] |
|
383 |
]. |
|
384 |
completionView selection: selection. |
|
385 |
]. |
|
386 |
^ false |
|
189
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
387 |
]. |
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
388 |
|
192
f27ce6dac101
Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
189
diff
changeset
|
389 |
matches2 := completionView list select:[:po | matcher2 value: prefix value: po stringToComplete ]. |
189
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
390 |
matches2 notEmptyOrNil ifTrue:[ |
917 | 391 |
matches2 size == 1 ifTrue:[ |
392 |
completionView selection: matches2 anElement. |
|
393 |
] ifFalse:[ |
|
394 |
| selection | |
|
189
8c32268000c5
Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
188
diff
changeset
|
395 |
|
917 | 396 |
selection := matches2 inject: matches2 anElement into:[:mostrelevant :each | |
397 |
each relevance > mostrelevant relevance |
|
398 |
ifTrue:[each] |
|
399 |
ifFalse:[mostrelevant] |
|
400 |
]. |
|
401 |
completionView selection: selection. |
|
402 |
] |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
403 |
] ifFalse:[ |
917 | 404 |
completionView selection: nil. |
153
b04d591c8788
Added relevance value to completion item. Pre-select the most relevant item in complection view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
143
diff
changeset
|
405 |
]. |
154
b96fbde91144
Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
153
diff
changeset
|
406 |
^ false. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
407 |
|
239
e1b7b5f0f4b7
Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
221
diff
changeset
|
408 |
"Created: / 17-06-2014 / 07:19:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
274
2cfcd8eb9761
Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
252
diff
changeset
|
409 |
"Modified: / 11-08-2014 / 14:52:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
410 |
! ! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
411 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
412 |
!CompletionController methodsFor:'private-API'! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
413 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
414 |
closeCompletionView |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
415 |
|v| |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
416 |
|
123
1b949542c4b2
Improvements for completion of Java classes/methods in Smalltalk code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
417 |
self stopCompletionProcess. |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
418 |
(v := completionView) notNil ifTrue:[ |
917 | 419 |
completionView := nil. |
420 |
"/ let it close itself - avoids synchronization problems |
|
421 |
v sensor |
|
422 |
pushUserEvent:#value |
|
423 |
for:[ v topView destroy ]. |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
424 |
]. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
425 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
426 |
"Created: / 02-10-2013 / 13:57:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
123
1b949542c4b2
Improvements for completion of Java classes/methods in Smalltalk code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
118
diff
changeset
|
427 |
"Modified: / 04-10-2013 / 21:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
428 |
! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
429 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
430 |
computeCompletions |
917 | 431 |
"Actually compute the completions and update the completion view." |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
432 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
433 |
| completions | |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
434 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
435 |
editView sensor flushUserEventsFor: self. |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
436 |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
437 |
"/ Wait a while to give user chance finish typing. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
438 |
"/ This also reduces CPU consumption by avoiding |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
439 |
"/ useless computation |
917 | 440 |
Delay waitForMilliseconds: 200. |
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
441 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
442 |
completions := self computeCompletionsInContext. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
443 |
completions notEmptyOrNil ifTrue:[ |
917 | 444 |
editView sensor pushUserEvent: #updateCompletions:sequence: for: self withArguments: (Array with: completions with: seqno) |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
445 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
446 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
447 |
"Created: / 27-09-2013 / 13:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
448 |
"Modified: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
449 |
! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
450 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
451 |
computeCompletionsInContext |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
452 |
| context | |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
453 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
454 |
context := CompletionContext new. |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
455 |
context environment: self environment. |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
456 |
context support: support. |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
457 |
^self computeCompletionsInContext: context. |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
458 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
459 |
"Created: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
460 |
! |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
461 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
462 |
computeCompletionsInContext: aCompletionContext |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
463 |
| engine | |
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
464 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
465 |
engine := self completionEngine. |
917 | 466 |
^engine notNil |
467 |
ifTrue:[ engine complete: aCompletionContext ] |
|
468 |
ifFalse:[ nil ] |
|
218
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
469 |
|
0f5b160ecb9d
Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
212
diff
changeset
|
470 |
"Created: / 18-05-2014 / 11:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
471 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
472 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
473 |
openCompletionView |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
474 |
self openCompletionView: #() |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
475 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
476 |
"Created: / 27-09-2013 / 16:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
477 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
478 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
479 |
openCompletionView: list |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
480 |
"Makes sure the completion view is opened and with given `list`." |
917 | 481 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
482 |
| movePos topView x y windowExtent screenExtent | |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
483 |
"/ move the window |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
484 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
485 |
list isEmpty ifTrue:[ ^ self ]. |
917 | 486 |
list = #( 'Busy...' ) ifTrue:[ ^ self ]. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
487 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
488 |
x := (editView xOfCol:editView cursorCol inVisibleLine:editView cursorLine) |
917 | 489 |
- 16"icon" - (editView widthOfString: "support wordBeforeCursor"list first stringAlreadyWritten) - 5"magic constant". |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
490 |
y := editView yOfCursor + editView font maxHeight + 3. |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
491 |
movePos := (editView originRelativeTo: nil) + (x @ y). |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
492 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
493 |
completionView isNil ifTrue:[ |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
494 |
|
917 | 495 |
completionView := CompletionView new. |
496 |
completionView completionController: self. |
|
497 |
completionView list:list. |
|
498 |
completionView font: editView font. |
|
499 |
topView := completionView. |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
500 |
|
917 | 501 |
windowExtent := completionView extent copy. |
502 |
screenExtent := Screen current monitorBoundsAt: movePos. |
|
503 |
(screenExtent height) < (movePos y + windowExtent y) ifTrue:[ |
|
504 |
movePos y: (movePos y - windowExtent y - editView font maxHeight - 5). |
|
505 |
]. |
|
506 |
topView origin:movePos. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
507 |
"/ topView resizeToFit. |
917 | 508 |
self updateSelection ifFalse:[ |
509 |
topView open. |
|
510 |
]. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
511 |
] ifFalse:[ |
917 | 512 |
completionView list:list. |
513 |
self updateSelection. |
|
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
514 |
"/ topView := completionView topView. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
515 |
"/ topView ~~ completionView ifTrue:[ |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
516 |
"/ topView origin:movePos. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
517 |
"/ topView resizeToFit. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
518 |
"/ ] |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
519 |
]. |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
520 |
|
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
521 |
"Created: / 27-09-2013 / 14:01:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
212
a2caebc602a7
Fixes and improvements for Java/Groovy completion (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
205
diff
changeset
|
522 |
"Modified: / 15-05-2014 / 11:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
523 |
! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
524 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
525 |
updateCompletions: completionResult sequence: sequence |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
526 |
seqno == sequence ifTrue:[ |
917 | 527 |
self openCompletionView: completionResult |
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
528 |
]. |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
529 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
530 |
"Created: / 03-10-2013 / 07:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
531 |
"Modified: / 03-10-2013 / 11:02:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
532 |
! ! |
441529422c2f
Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
533 |
|
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
534 |
!CompletionController class methodsFor:'documentation'! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
535 |
|
926 | 536 |
version |
537 |
^ '$Header$' |
|
538 |
! |
|
539 |
||
540 |
version_CVS |
|
541 |
^ '$Header$' |
|
542 |
! |
|
543 |
||
118
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
544 |
version_HG |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
545 |
|
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
546 |
^ '$Changeset: <not expanded> $' |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
547 |
! ! |
88e6fd734a11
Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
117
diff
changeset
|
548 |