author | sr |
Tue, 03 Jul 2018 13:42:12 +0200 | |
changeset 6370 | b5cd4fd52b3c |
parent 6315 | 1362b6366e09 |
child 6391 | 935a745d3c55 |
permissions | -rw-r--r-- |
6315 | 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 |
[ |
|
5697 | 256 |
"/ protect end-user applications from errors |
257 |
Error handle:[:ex | |
|
258 |
Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ ex reject ] |
|
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>" |
|
271 |
! |
|
272 |
||
273 |
stopCompletionProcess |
|
274 |
"kill any background completion process" |
|
275 |
||
276 |
|p| |
|
277 |
||
278 |
(p := completionProcess) notNil ifTrue:[ |
|
279 |
completionProcess := nil. |
|
280 |
p terminate. |
|
281 |
]. |
|
282 |
! |
|
283 |
||
284 |
updateCompletionList |
|
285 |
"called for keypress events" |
|
286 |
||
287 |
self startCompletionProcess. |
|
288 |
! ! |
|
289 |
||
290 |
!EditTextViewCompletionSupport methodsFor:'private-API'! |
|
291 |
||
292 |
closeCompletionView |
|
293 |
|v| |
|
294 |
||
295 |
(v := completionView) notNil ifTrue:[ |
|
296 |
completionView := nil. |
|
297 |
"/ let it close itself - avoids synchronization problems |
|
298 |
v sensor |
|
299 |
pushUserEvent:#value |
|
300 |
for:[ v topView destroy ] |
|
301 |
]. |
|
302 |
! |
|
303 |
||
304 |
openCompletionView |
|
305 |
"Opens the completion view with an initial list. Called as soon as |
|
306 |
completion is initiated but completion options are not yet computed." |
|
307 |
||
308 |
self openCompletionView: (Array with: 'Busy...') |
|
309 |
||
310 |
"Created: / 26-09-2013 / 17:06:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
311 |
! |
|
312 |
||
313 |
openCompletionView: list |
|
314 |
"Makes sure the completion view is opened and with given `list`." |
|
315 |
||
5939 | 316 |
| textCursorPosInTextView textCursorPosOnScreen movePos topView |
317 |
screenBounds screenBoundsCorner |
|
318 |
helpViewsExtent helpViewsWidth helpViewsHeight| |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
319 |
|
5939 | 320 |
"/ move the window away from the text cursor (to not cover what user types in) |
321 |
"/ get the screen-relative position of the text cursor |
|
322 |
textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
|
323 |
||
324 |
"/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
|
325 |
textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
|
326 |
||
327 |
textCursorPosOnScreen := editView device |
|
328 |
translatePoint:textCursorPosInTextView |
|
329 |
fromView:editView toView:nil. |
|
330 |
||
4788 | 331 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
5939 | 332 |
"/ this will be somewhat to the down-right of the textCursor |
333 |
movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
|
4788 | 334 |
|
335 |
completionView isNil ifTrue:[ |
|
336 |
completionView := CodeCompletionHelpMenuView new. |
|
337 |
completionView name:'completion'. |
|
338 |
completionView level:0. |
|
339 |
completionView list:list. |
|
340 |
completionView enable:false. |
|
341 |
completionView extent:completionView preferredExtentForContents. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
342 |
"/ completionView font: editView font. |
4788 | 343 |
topView := CodeCompletionHelpView with:completionView. |
4968
254b5e81199a
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4824
diff
changeset
|
344 |
topView editView:editView. |
4788 | 345 |
] ifFalse:[ |
346 |
completionView list:list. |
|
347 |
topView := completionView topView. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
348 |
]. |
5939 | 349 |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
350 |
topView ~~ completionView ifTrue:[ |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
351 |
topView resizeToFit. |
5939 | 352 |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
353 |
"/ make sure, the window is visible |
5939 | 354 |
screenBounds := topView device monitorBoundsAt:topView origin. |
355 |
screenBoundsCorner := screenBounds corner. |
|
356 |
||
357 |
helpViewsExtent := topView extent. |
|
358 |
helpViewsWidth := helpViewsExtent x. |
|
359 |
helpViewsHeight := helpViewsExtent y. |
|
360 |
||
361 |
"/ if it does not lie completely inside the screen, move it |
|
362 |
(movePos x + helpViewsWidth) > screenBoundsCorner x ifTrue:[ |
|
363 |
movePos := (textCursorPosOnScreen x - 60 - helpViewsWidth) @ movePos y. |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
364 |
]. |
5939 | 365 |
(movePos y + helpViewsHeight) > screenBoundsCorner y ifTrue:[ |
366 |
movePos := movePos x @ (textCursorPosOnScreen y - helpViewsHeight). |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
367 |
]. |
5939 | 368 |
movePos y < 0 ifTrue:[ |
369 |
movePos := movePos x @ 0 |
|
370 |
]. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
371 |
topView origin:movePos. |
4788 | 372 |
]. |
373 |
||
374 |
"Created: / 26-09-2013 / 17:07:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
375 |
! ! |
|
376 |
||
377 |
!EditTextViewCompletionSupport class methodsFor:'documentation'! |
|
378 |
||
379 |
version |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
380 |
^ '$Header$' |
4788 | 381 |
! |
382 |
||
383 |
version_CVS |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
384 |
^ '$Header$' |
4788 | 385 |
! ! |
386 |