author | Claus Gittinger <cg@exept.de> |
Sat, 13 Jul 2019 14:10:43 +0200 | |
changeset 6627 | 322e0fc5efc4 |
parent 6594 | c347f9e598d7 |
child 6632 | 8670224f9fd5 |
permissions | -rw-r--r-- |
4788 | 1 |
"{ Package: 'stx:libwidg' }" |
2 |
||
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
4 |
|
4788 | 5 |
Object subclass:#EditTextViewCompletionSupport |
5772 | 6 |
instanceVariableNames:'completionView completionProcess editView autoSelect |
7 |
editViewLostFocusBlock' |
|
4788 | 8 |
classVariableNames:'LastCompletions' |
9 |
poolDictionaries:'' |
|
10 |
category:'Views-Text' |
|
11 |
! |
|
12 |
||
13 |
!EditTextViewCompletionSupport class methodsFor:'documentation'! |
|
14 |
||
15 |
documentation |
|
16 |
" |
|
17 |
An abstract supperclass to support completion in text views. |
|
18 |
Individual completion engines may create a subclass of |
|
19 |
EditTextCompletionSupport and customize it. |
|
20 |
||
5788 | 21 |
Basically, they have to implement #computeCompletions |
4788 | 22 |
|
23 |
[author:] |
|
24 |
Claus Gittinger |
|
25 |
||
26 |
[instance variables:] |
|
27 |
||
28 |
[class variables:] |
|
29 |
||
30 |
[see also:] |
|
31 |
||
32 |
" |
|
33 |
! ! |
|
34 |
||
35 |
!EditTextViewCompletionSupport class methodsFor:'instance creation'! |
|
36 |
||
37 |
for:anEditView |
|
38 |
^ self new editView:anEditView |
|
39 |
! ! |
|
40 |
||
41 |
!EditTextViewCompletionSupport class methodsFor:'queries'! |
|
42 |
||
43 |
isAbstract |
|
5509 | 44 |
^ self == EditTextViewCompletionSupport |
4788 | 45 |
|
46 |
"Created: / 26-09-2013 / 16:22:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
47 |
! ! |
|
48 |
||
49 |
!EditTextViewCompletionSupport methodsFor:'accessing'! |
|
50 |
||
51 |
editView:anEditTextView |
|
52 |
editView := anEditTextView. |
|
53 |
! ! |
|
54 |
||
55 |
!EditTextViewCompletionSupport methodsFor:'events'! |
|
56 |
||
57 |
buttonPress:button x:x y:y |
|
58 |
self closeCompletionView. |
|
59 |
! |
|
60 |
||
61 |
editViewLostFocus |
|
5772 | 62 |
"this is a hack for Windows: |
63 |
on windows, an activate:false event is first sent to my textView, |
|
64 |
then an activate is sent to the completion popup. |
|
65 |
this is done BEFORE the buttonPress event is delivered. |
|
5891 | 66 |
therefore, allow for the activate of the completionMenu and its button event to be processed. |
5772 | 67 |
before forcing it to be closed..." |
68 |
||
4788 | 69 |
completionView notNil ifTrue:[ |
4808
b37597d2df93
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4805
diff
changeset
|
70 |
editView graphicsDevice anyButtonPressed ifTrue:[ |
b37597d2df93
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4805
diff
changeset
|
71 |
editView sensor pushUserEvent:#editViewLostFocus for:self. |
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
72 |
] ifFalse:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
73 |
self closeCompletionView |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
74 |
] |
4808
b37597d2df93
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4805
diff
changeset
|
75 |
]. |
4788 | 76 |
! |
77 |
||
78 |
handleKeyPress:key x:x y:y |
|
79 |
"return true, if I have eaten this keypress" |
|
80 |
||
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
81 |
|ch completeImmediate eatCursorLeftOrRight eatCursorUpDown| |
4788 | 82 |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
83 |
"/ completeImmediate := UserPreferences current immediateCodeCompletion. |
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
84 |
|
4788 | 85 |
"/ open on CTRL- or TAB-key? |
6370 | 86 |
(completionView notNil and:[completionView realized]) ifFalse:[ |
4788 | 87 |
editView hasSelection ifFalse:[ |
88 |
((ch := editView characterBeforeCursor) notNil "/ i.e. not at begin of line |
|
6594 | 89 |
and:[ ch isLetterOrDigitOrUnderline ]) ifTrue:[ |
4788 | 90 |
(key == #Control_L or:[ key == #Ctrl or:[ key == #Control_R or:[ key == #Control]]]) ifTrue:[ |
91 |
UserPreferences current codeCompletionOnControlKey ifTrue:[ |
|
92 |
autoSelect := true. |
|
93 |
self updateCompletionList |
|
94 |
] |
|
95 |
]. |
|
4805
dd3fd2a4f3e9
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4788
diff
changeset
|
96 |
((key == #Tab) and:[editView sensor shiftDown not]) ifTrue:[ |
4788 | 97 |
UserPreferences current codeCompletionOnTabKey ifTrue:[ |
6315 | 98 |
"/ only if the character after the cursor is a separator!! |
99 |
"/ otherwise, we cannot insert tabs |
|
6370 | 100 |
((ch := editView characterAfterCursor) isNil or:[ch isSeparator]) ifTrue:[ |
6315 | 101 |
autoSelect := true. |
102 |
self updateCompletionList. |
|
103 |
^ true |
|
104 |
]. |
|
4788 | 105 |
]. |
106 |
] |
|
107 |
]. |
|
108 |
]. |
|
109 |
^ false. |
|
110 |
]. |
|
111 |
||
6197 | 112 |
editView cursorCol <= 1 ifTrue:[^ false]. |
113 |
||
4788 | 114 |
"/ key for completion view ? (careful: do not forward too many, it would disturb user's typing) |
115 |
key isCharacter ifFalse:[ |
|
116 |
"/ forward to menu |
|
117 |
(completionView notNil) ifTrue:[ |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
118 |
"/never |
4788 | 119 |
eatCursorLeftOrRight := false. |
120 |
"/ completeImmediate not |
|
121 |
"/ or:[ editView sensor shiftDown |
|
122 |
"/ or:[ editView sensor ctrlDown ]]. |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
123 |
"/ only with shift or ctrl |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
124 |
eatCursorUpDown := |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
125 |
(UserPreferences current codeCompletionViewKeyboardNavigationNeedsModifier not) |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
126 |
or:[ editView sensor shiftDown |
5705 | 127 |
or:[ editView sensor ctrlDown]]. |
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
128 |
|
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
129 |
((key == #CursorDown and:[eatCursorUpDown]) |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
130 |
or:[ (key == #CursorUp and:[eatCursorUpDown]) |
4788 | 131 |
or:[ ((key == #CursorLeft) and:[eatCursorLeftOrRight]) |
132 |
or:[ ((key == #CursorRight) and:[eatCursorLeftOrRight]) |
|
133 |
or:[ ((key == #Return) and:[ completionView hasSelection ]) |
|
134 |
]]]]) ifTrue:[ |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
135 |
"/ forward to completion view |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
136 |
completionView sensor pushUserEvent:#value for:[ completionView keyPress:key x:0 y:0 ]. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
137 |
^ true. |
4788 | 138 |
]. |
139 |
||
140 |
(key == #Control_L or:[ key == #Control_R or:[ key == #Control or:[ key == #Ctrl ]]]) ifTrue:[ |
|
141 |
"/ CTRL is a toggle |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
142 |
"/ self closeCompletionView. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
143 |
"/ ^ true. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
144 |
^ false "/ don't eat |
4788 | 145 |
]. |
146 |
(key == #Escape) ifTrue:[ |
|
147 |
self closeCompletionView. |
|
148 |
^ true "/ EAT |
|
149 |
]. |
|
150 |
"/ shift does not close |
|
151 |
(key == #Shift_L or:[ key == #Shift_R or:[ key == #Shift]]) ifTrue:[ |
|
152 |
^ false "/ don' eat |
|
153 |
]. |
|
154 |
||
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
155 |
(key == #BackSpace) ifTrue:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
156 |
^ false "/ don' eat |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
157 |
]. |
4788 | 158 |
self closeCompletionView. |
159 |
^ false "/ don' eat |
|
160 |
]. |
|
161 |
]. |
|
162 |
^ false. |
|
6197 | 163 |
|
164 |
"Modified: / 24-08-2017 / 21:32:52 / cg" |
|
6370 | 165 |
"Modified: / 03-07-2018 / 13:41:45 / sr" |
6594 | 166 |
"Modified: / 05-06-2019 / 17:06:15 / Claus Gittinger" |
4788 | 167 |
! |
168 |
||
169 |
postKeyPress:key |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
170 |
|doComplete| |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
171 |
|
4788 | 172 |
UserPreferences current immediateCodeCompletion ifFalse:[ |
173 |
"/ only update, if already open |
|
174 |
completionView isNil ifTrue:[^ self]. |
|
175 |
]. |
|
176 |
||
177 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
|
178 |
autoSelect := false. |
|
179 |
self updateCompletionList. |
|
180 |
^ self |
|
181 |
]. |
|
182 |
||
183 |
key isCharacter ifTrue:[ |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
184 |
(doComplete := key isSeparator not) ifFalse:[ |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
185 |
"/ also on a separator, but only if at the end of a non-empty line |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
186 |
doComplete := editView lineStringBeforeCursor withoutSeparators notEmpty. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
187 |
]. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
188 |
doComplete ifFalse:[ |
4788 | 189 |
self closeCompletionView |
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
190 |
] ifTrue:[ |
4788 | 191 |
autoSelect := false. |
192 |
self updateCompletionList. |
|
193 |
]. |
|
194 |
^ self |
|
195 |
]. |
|
5772 | 196 |
! |
197 |
||
198 |
startTimeoutForEditViewLostFocus |
|
199 |
"see comment in #editViewLostFocus" |
|
200 |
||
201 |
editViewLostFocusBlock isNil ifTrue:[ |
|
202 |
editViewLostFocusBlock := [self editViewLostFocus]. |
|
203 |
]. |
|
204 |
Processor addTimedBlock:editViewLostFocusBlock afterMilliseconds:200. |
|
4788 | 205 |
! ! |
206 |
||
207 |
!EditTextViewCompletionSupport methodsFor:'private'! |
|
208 |
||
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
209 |
computeCompletions |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
210 |
"Actually compute the completions and update the completion view." |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
211 |
|
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
212 |
self subclassResponsibility |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
213 |
|
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
214 |
"Created: / 26-09-2013 / 17:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
215 |
! |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
216 |
|
4788 | 217 |
release |
218 |
self stopCompletionProcess. |
|
219 |
self closeCompletionView. |
|
220 |
super release |
|
221 |
! |
|
222 |
||
223 |
startCompletionProcess |
|
224 |
"start the code completion process in the background" |
|
225 |
||
6627 | 226 |
|initialList cursorX cursorY p| |
4788 | 227 |
|
228 |
"/ terminate any previous process |
|
229 |
self stopCompletionProcess. |
|
230 |
||
231 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
232 |
"/ 'cl' printCR. |
4788 | 233 |
self closeCompletionView. |
234 |
^ self |
|
235 |
]. |
|
236 |
((cursorX := editView xOfCursor) isNil |
|
237 |
or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[ |
|
238 |
"/ no cursor - user is selecting, or cursor has been scrolled out of sight. |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
239 |
"/ 'cl2' printCR. |
4788 | 240 |
self closeCompletionView. |
241 |
^ self |
|
242 |
]. |
|
243 |
||
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
244 |
completionView isNil ifTrue:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
245 |
initialList := #( 'Busy...' ). |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
246 |
"/ 'op1' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
247 |
] ifFalse:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
248 |
initialList := completionView list. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
249 |
"/ 'op2' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
250 |
]. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
251 |
self openCompletionView:initialList. |
4788 | 252 |
|
6627 | 253 |
completionProcess := p := |
4788 | 254 |
[ |
6432 | 255 |
[ |
256 |
"/ protect end-user applications from errors |
|
257 |
Error handle:[:ex | |
|
258 |
(ParseError accepts:ex creator) ifFalse:[ |
|
259 |
Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ ex reject ] |
|
260 |
]. |
|
261 |
] do:[ |
|
262 |
(editView topView isDebugView) ifTrue:[ |
|
263 |
ControlInterrupt ignoreIn:[ |
|
264 |
self computeCompletions. |
|
265 |
]. |
|
266 |
] ifFalse:[ |
|
267 |
self computeCompletions. |
|
268 |
]. |
|
6391 | 269 |
]. |
6627 | 270 |
p == completionProcess ifTrue:[ |
271 |
completionProcess := nil |
|
272 |
] |
|
6432 | 273 |
] ifCurtailed:[ |
6433 | 274 |
"/ completionView notNil ifTrue:[ |
275 |
"/ completionView topView destroy |
|
276 |
"/ ]. |
|
6432 | 277 |
]. |
6627 | 278 |
] newProcess. |
279 |
"/ p priority:(Processor activePriority - 1). |
|
280 |
p priorityRange:(Processor activePriority-1 to:Processor activePriority). |
|
281 |
p resume. |
|
4788 | 282 |
|
283 |
"Modified: / 26-09-2013 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6433 | 284 |
"Modified: / 15-09-2018 / 12:40:59 / Claus Gittinger" |
4788 | 285 |
! |
286 |
||
287 |
stopCompletionProcess |
|
288 |
"kill any background completion process" |
|
289 |
||
290 |
|p| |
|
291 |
||
292 |
(p := completionProcess) notNil ifTrue:[ |
|
293 |
completionProcess := nil. |
|
294 |
p terminate. |
|
295 |
]. |
|
296 |
! |
|
297 |
||
298 |
updateCompletionList |
|
299 |
"called for keypress events" |
|
300 |
||
301 |
self startCompletionProcess. |
|
302 |
! ! |
|
303 |
||
304 |
!EditTextViewCompletionSupport methodsFor:'private-API'! |
|
305 |
||
306 |
closeCompletionView |
|
307 |
|v| |
|
308 |
||
309 |
(v := completionView) notNil ifTrue:[ |
|
310 |
completionView := nil. |
|
6432 | 311 |
|
4788 | 312 |
"/ let it close itself - avoids synchronization problems |
313 |
v sensor |
|
314 |
pushUserEvent:#value |
|
315 |
for:[ v topView destroy ] |
|
316 |
]. |
|
6432 | 317 |
|
318 |
"Modified (format): / 14-09-2018 / 22:08:05 / Claus Gittinger" |
|
4788 | 319 |
! |
320 |
||
321 |
openCompletionView |
|
322 |
"Opens the completion view with an initial list. Called as soon as |
|
323 |
completion is initiated but completion options are not yet computed." |
|
324 |
||
325 |
self openCompletionView: (Array with: 'Busy...') |
|
326 |
||
327 |
"Created: / 26-09-2013 / 17:06:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
328 |
! |
|
329 |
||
330 |
openCompletionView: list |
|
331 |
"Makes sure the completion view is opened and with given `list`." |
|
332 |
||
5939 | 333 |
| textCursorPosInTextView textCursorPosOnScreen movePos topView |
334 |
screenBounds screenBoundsCorner |
|
335 |
helpViewsExtent helpViewsWidth helpViewsHeight| |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
336 |
|
5939 | 337 |
"/ move the window away from the text cursor (to not cover what user types in) |
338 |
"/ get the screen-relative position of the text cursor |
|
339 |
textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
|
340 |
||
341 |
"/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
|
342 |
textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
|
343 |
||
344 |
textCursorPosOnScreen := editView device |
|
345 |
translatePoint:textCursorPosInTextView |
|
346 |
fromView:editView toView:nil. |
|
347 |
||
4788 | 348 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
5939 | 349 |
"/ this will be somewhat to the down-right of the textCursor |
350 |
movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
|
4788 | 351 |
|
352 |
completionView isNil ifTrue:[ |
|
353 |
completionView := CodeCompletionHelpMenuView new. |
|
354 |
completionView name:'completion'. |
|
355 |
completionView level:0. |
|
356 |
completionView list:list. |
|
357 |
completionView enable:false. |
|
358 |
completionView extent:completionView preferredExtentForContents. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
359 |
"/ completionView font: editView font. |
4788 | 360 |
topView := CodeCompletionHelpView with:completionView. |
4968
254b5e81199a
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4824
diff
changeset
|
361 |
topView editView:editView. |
4788 | 362 |
] ifFalse:[ |
363 |
completionView list:list. |
|
364 |
topView := completionView topView. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
365 |
]. |
5939 | 366 |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
367 |
topView ~~ completionView ifTrue:[ |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
368 |
topView resizeToFit. |
5939 | 369 |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
370 |
"/ make sure, the window is visible |
5939 | 371 |
screenBounds := topView device monitorBoundsAt:topView origin. |
372 |
screenBoundsCorner := screenBounds corner. |
|
373 |
||
374 |
helpViewsExtent := topView extent. |
|
375 |
helpViewsWidth := helpViewsExtent x. |
|
376 |
helpViewsHeight := helpViewsExtent y. |
|
377 |
||
378 |
"/ if it does not lie completely inside the screen, move it |
|
379 |
(movePos x + helpViewsWidth) > screenBoundsCorner x ifTrue:[ |
|
380 |
movePos := (textCursorPosOnScreen x - 60 - helpViewsWidth) @ movePos y. |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
381 |
]. |
5939 | 382 |
(movePos y + helpViewsHeight) > screenBoundsCorner y ifTrue:[ |
383 |
movePos := movePos x @ (textCursorPosOnScreen y - helpViewsHeight). |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
384 |
]. |
5939 | 385 |
movePos y < 0 ifTrue:[ |
386 |
movePos := movePos x @ 0 |
|
387 |
]. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
388 |
topView origin:movePos. |
4788 | 389 |
]. |
390 |
||
391 |
"Created: / 26-09-2013 / 17:07:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
392 |
! ! |
|
393 |
||
6391 | 394 |
|
4788 | 395 |
!EditTextViewCompletionSupport class methodsFor:'documentation'! |
396 |
||
397 |
version |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
398 |
^ '$Header$' |
4788 | 399 |
! |
400 |
||
401 |
version_CVS |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
402 |
^ '$Header$' |
4788 | 403 |
! ! |
404 |