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