author | Claus Gittinger <cg@exept.de> |
Mon, 13 Aug 2018 09:43:00 +0200 | |
changeset 6391 | 935a745d3c55 |
parent 6370 | b5cd4fd52b3c |
child 6432 | 03625766b591 |
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 |
|
5411
fa4c9122e6ef
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5410
diff
changeset
|
89 |
and:[ ch isLetterOrDigit or:[ ch == $_ ] ]) 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" |
4788 | 166 |
! |
167 |
||
168 |
postKeyPress:key |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
169 |
|doComplete| |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
170 |
|
4788 | 171 |
UserPreferences current immediateCodeCompletion ifFalse:[ |
172 |
"/ only update, if already open |
|
173 |
completionView isNil ifTrue:[^ self]. |
|
174 |
]. |
|
175 |
||
176 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
|
177 |
autoSelect := false. |
|
178 |
self updateCompletionList. |
|
179 |
^ self |
|
180 |
]. |
|
181 |
||
182 |
key isCharacter ifTrue:[ |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
183 |
(doComplete := key isSeparator not) ifFalse:[ |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
184 |
"/ 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
|
185 |
doComplete := editView lineStringBeforeCursor withoutSeparators notEmpty. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
186 |
]. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
187 |
doComplete ifFalse:[ |
4788 | 188 |
self closeCompletionView |
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
189 |
] ifTrue:[ |
4788 | 190 |
autoSelect := false. |
191 |
self updateCompletionList. |
|
192 |
]. |
|
193 |
^ self |
|
194 |
]. |
|
5772 | 195 |
! |
196 |
||
197 |
startTimeoutForEditViewLostFocus |
|
198 |
"see comment in #editViewLostFocus" |
|
199 |
||
200 |
editViewLostFocusBlock isNil ifTrue:[ |
|
201 |
editViewLostFocusBlock := [self editViewLostFocus]. |
|
202 |
]. |
|
203 |
Processor addTimedBlock:editViewLostFocusBlock afterMilliseconds:200. |
|
4788 | 204 |
! ! |
205 |
||
206 |
!EditTextViewCompletionSupport methodsFor:'private'! |
|
207 |
||
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
208 |
computeCompletions |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
209 |
"Actually compute the completions and update the completion view." |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
210 |
|
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
211 |
self subclassResponsibility |
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 |
"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
|
214 |
! |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
215 |
|
4788 | 216 |
release |
217 |
self stopCompletionProcess. |
|
218 |
self closeCompletionView. |
|
219 |
super release |
|
220 |
! |
|
221 |
||
222 |
startCompletionProcess |
|
223 |
"start the code completion process in the background" |
|
224 |
||
225 |
|initialList cursorX cursorY| |
|
226 |
||
227 |
"/ terminate any previous process |
|
228 |
self stopCompletionProcess. |
|
229 |
||
230 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
231 |
"/ 'cl' printCR. |
4788 | 232 |
self closeCompletionView. |
233 |
^ self |
|
234 |
]. |
|
235 |
((cursorX := editView xOfCursor) isNil |
|
236 |
or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[ |
|
237 |
"/ 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
|
238 |
"/ 'cl2' printCR. |
4788 | 239 |
self closeCompletionView. |
240 |
^ self |
|
241 |
]. |
|
242 |
||
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
243 |
completionView isNil ifTrue:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
244 |
initialList := #( 'Busy...' ). |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
245 |
"/ 'op1' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
246 |
] ifFalse:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
247 |
initialList := completionView list. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
248 |
"/ 'op2' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
249 |
]. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
250 |
self openCompletionView:initialList. |
4788 | 251 |
|
252 |
completionProcess := |
|
253 |
[ |
|
5697 | 254 |
"/ protect end-user applications from errors |
255 |
Error handle:[:ex | |
|
6391 | 256 |
(ParseError accepts:ex creator) ifFalse:[ |
257 |
Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ ex reject ] |
|
258 |
]. |
|
5960 | 259 |
] do:[ |
5995 | 260 |
(editView topView isDebugView) ifTrue:[ |
5960 | 261 |
ControlInterrupt ignoreIn:[ |
262 |
self computeCompletions. |
|
263 |
]. |
|
264 |
] ifFalse:[ |
|
265 |
self computeCompletions. |
|
266 |
]. |
|
5697 | 267 |
]. |
4788 | 268 |
] forkAt:(Processor activePriority - 1). |
269 |
||
270 |
"Modified: / 26-09-2013 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6391 | 271 |
"Modified: / 13-08-2018 / 08:49:42 / Claus Gittinger" |
4788 | 272 |
! |
273 |
||
274 |
stopCompletionProcess |
|
275 |
"kill any background completion process" |
|
276 |
||
277 |
|p| |
|
278 |
||
279 |
(p := completionProcess) notNil ifTrue:[ |
|
280 |
completionProcess := nil. |
|
281 |
p terminate. |
|
282 |
]. |
|
283 |
! |
|
284 |
||
285 |
updateCompletionList |
|
286 |
"called for keypress events" |
|
287 |
||
288 |
self startCompletionProcess. |
|
289 |
! ! |
|
290 |
||
291 |
!EditTextViewCompletionSupport methodsFor:'private-API'! |
|
292 |
||
293 |
closeCompletionView |
|
294 |
|v| |
|
295 |
||
296 |
(v := completionView) notNil ifTrue:[ |
|
297 |
completionView := nil. |
|
298 |
"/ let it close itself - avoids synchronization problems |
|
299 |
v sensor |
|
300 |
pushUserEvent:#value |
|
301 |
for:[ v topView destroy ] |
|
302 |
]. |
|
303 |
! |
|
304 |
||
305 |
openCompletionView |
|
306 |
"Opens the completion view with an initial list. Called as soon as |
|
307 |
completion is initiated but completion options are not yet computed." |
|
308 |
||
309 |
self openCompletionView: (Array with: 'Busy...') |
|
310 |
||
311 |
"Created: / 26-09-2013 / 17:06:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
312 |
! |
|
313 |
||
314 |
openCompletionView: list |
|
315 |
"Makes sure the completion view is opened and with given `list`." |
|
316 |
||
5939 | 317 |
| textCursorPosInTextView textCursorPosOnScreen movePos topView |
318 |
screenBounds screenBoundsCorner |
|
319 |
helpViewsExtent helpViewsWidth helpViewsHeight| |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
320 |
|
5939 | 321 |
"/ move the window away from the text cursor (to not cover what user types in) |
322 |
"/ get the screen-relative position of the text cursor |
|
323 |
textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
|
324 |
||
325 |
"/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
|
326 |
textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
|
327 |
||
328 |
textCursorPosOnScreen := editView device |
|
329 |
translatePoint:textCursorPosInTextView |
|
330 |
fromView:editView toView:nil. |
|
331 |
||
4788 | 332 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
5939 | 333 |
"/ this will be somewhat to the down-right of the textCursor |
334 |
movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
|
4788 | 335 |
|
336 |
completionView isNil ifTrue:[ |
|
337 |
completionView := CodeCompletionHelpMenuView new. |
|
338 |
completionView name:'completion'. |
|
339 |
completionView level:0. |
|
340 |
completionView list:list. |
|
341 |
completionView enable:false. |
|
342 |
completionView extent:completionView preferredExtentForContents. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
343 |
"/ completionView font: editView font. |
4788 | 344 |
topView := CodeCompletionHelpView with:completionView. |
4968
254b5e81199a
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4824
diff
changeset
|
345 |
topView editView:editView. |
4788 | 346 |
] ifFalse:[ |
347 |
completionView list:list. |
|
348 |
topView := completionView topView. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
349 |
]. |
5939 | 350 |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
351 |
topView ~~ completionView ifTrue:[ |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
352 |
topView resizeToFit. |
5939 | 353 |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
354 |
"/ make sure, the window is visible |
5939 | 355 |
screenBounds := topView device monitorBoundsAt:topView origin. |
356 |
screenBoundsCorner := screenBounds corner. |
|
357 |
||
358 |
helpViewsExtent := topView extent. |
|
359 |
helpViewsWidth := helpViewsExtent x. |
|
360 |
helpViewsHeight := helpViewsExtent y. |
|
361 |
||
362 |
"/ if it does not lie completely inside the screen, move it |
|
363 |
(movePos x + helpViewsWidth) > screenBoundsCorner x ifTrue:[ |
|
364 |
movePos := (textCursorPosOnScreen x - 60 - helpViewsWidth) @ movePos y. |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
365 |
]. |
5939 | 366 |
(movePos y + helpViewsHeight) > screenBoundsCorner y ifTrue:[ |
367 |
movePos := movePos x @ (textCursorPosOnScreen y - helpViewsHeight). |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
368 |
]. |
5939 | 369 |
movePos y < 0 ifTrue:[ |
370 |
movePos := movePos x @ 0 |
|
371 |
]. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
372 |
topView origin:movePos. |
4788 | 373 |
]. |
374 |
||
375 |
"Created: / 26-09-2013 / 17:07:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
376 |
! ! |
|
377 |
||
6391 | 378 |
|
4788 | 379 |
!EditTextViewCompletionSupport class methodsFor:'documentation'! |
380 |
||
381 |
version |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
382 |
^ '$Header$' |
4788 | 383 |
! |
384 |
||
385 |
version_CVS |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
386 |
^ '$Header$' |
4788 | 387 |
! ! |
388 |