author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6197 | 3a3a1cabb663 |
child 6315 | 1362b6366e09 |
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? |
86 |
(completionView isNil or:[completionView realized not]) ifTrue:[ |
|
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:[ |
98 |
autoSelect := true. |
|
99 |
self updateCompletionList. |
|
100 |
^ true |
|
101 |
]. |
|
102 |
] |
|
103 |
]. |
|
104 |
]. |
|
105 |
^ false. |
|
106 |
]. |
|
107 |
||
6197 | 108 |
editView cursorCol <= 1 ifTrue:[^ false]. |
109 |
||
4788 | 110 |
"/ key for completion view ? (careful: do not forward too many, it would disturb user's typing) |
111 |
key isCharacter ifFalse:[ |
|
112 |
"/ forward to menu |
|
113 |
(completionView notNil) ifTrue:[ |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
114 |
"/never |
4788 | 115 |
eatCursorLeftOrRight := false. |
116 |
"/ completeImmediate not |
|
117 |
"/ or:[ editView sensor shiftDown |
|
118 |
"/ or:[ editView sensor ctrlDown ]]. |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
119 |
"/ only with shift or ctrl |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
120 |
eatCursorUpDown := |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
121 |
(UserPreferences current codeCompletionViewKeyboardNavigationNeedsModifier not) |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
122 |
or:[ editView sensor shiftDown |
5705 | 123 |
or:[ editView sensor ctrlDown]]. |
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
124 |
|
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
125 |
((key == #CursorDown and:[eatCursorUpDown]) |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
126 |
or:[ (key == #CursorUp and:[eatCursorUpDown]) |
4788 | 127 |
or:[ ((key == #CursorLeft) and:[eatCursorLeftOrRight]) |
128 |
or:[ ((key == #CursorRight) and:[eatCursorLeftOrRight]) |
|
129 |
or:[ ((key == #Return) and:[ completionView hasSelection ]) |
|
130 |
]]]]) ifTrue:[ |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
131 |
"/ forward to completion view |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
132 |
completionView sensor pushUserEvent:#value for:[ completionView keyPress:key x:0 y:0 ]. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
133 |
^ true. |
4788 | 134 |
]. |
135 |
||
136 |
(key == #Control_L or:[ key == #Control_R or:[ key == #Control or:[ key == #Ctrl ]]]) ifTrue:[ |
|
137 |
"/ CTRL is a toggle |
|
5064
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
138 |
"/ self closeCompletionView. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
139 |
"/ ^ true. |
55e4260c1ea1
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5033
diff
changeset
|
140 |
^ false "/ don't eat |
4788 | 141 |
]. |
142 |
(key == #Escape) ifTrue:[ |
|
143 |
self closeCompletionView. |
|
144 |
^ true "/ EAT |
|
145 |
]. |
|
146 |
"/ shift does not close |
|
147 |
(key == #Shift_L or:[ key == #Shift_R or:[ key == #Shift]]) ifTrue:[ |
|
148 |
^ false "/ don' eat |
|
149 |
]. |
|
150 |
||
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
151 |
(key == #BackSpace) ifTrue:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
152 |
^ false "/ don' eat |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
153 |
]. |
4788 | 154 |
self closeCompletionView. |
155 |
^ false "/ don' eat |
|
156 |
]. |
|
157 |
]. |
|
158 |
^ false. |
|
6197 | 159 |
|
160 |
"Modified: / 24-08-2017 / 21:32:52 / cg" |
|
4788 | 161 |
! |
162 |
||
163 |
postKeyPress:key |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
164 |
|doComplete| |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
165 |
|
4788 | 166 |
UserPreferences current immediateCodeCompletion ifFalse:[ |
167 |
"/ only update, if already open |
|
168 |
completionView isNil ifTrue:[^ self]. |
|
169 |
]. |
|
170 |
||
171 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
|
172 |
autoSelect := false. |
|
173 |
self updateCompletionList. |
|
174 |
^ self |
|
175 |
]. |
|
176 |
||
177 |
key isCharacter ifTrue:[ |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
178 |
(doComplete := key isSeparator not) ifFalse:[ |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
179 |
"/ 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
|
180 |
doComplete := editView lineStringBeforeCursor withoutSeparators notEmpty. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
181 |
]. |
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
182 |
doComplete ifFalse:[ |
4788 | 183 |
self closeCompletionView |
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
184 |
] ifTrue:[ |
4788 | 185 |
autoSelect := false. |
186 |
self updateCompletionList. |
|
187 |
]. |
|
188 |
^ self |
|
189 |
]. |
|
5772 | 190 |
! |
191 |
||
192 |
startTimeoutForEditViewLostFocus |
|
193 |
"see comment in #editViewLostFocus" |
|
194 |
||
195 |
editViewLostFocusBlock isNil ifTrue:[ |
|
196 |
editViewLostFocusBlock := [self editViewLostFocus]. |
|
197 |
]. |
|
198 |
Processor addTimedBlock:editViewLostFocusBlock afterMilliseconds:200. |
|
4788 | 199 |
! ! |
200 |
||
201 |
!EditTextViewCompletionSupport methodsFor:'private'! |
|
202 |
||
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
203 |
computeCompletions |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
204 |
"Actually compute the completions and update the completion view." |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
205 |
|
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
206 |
self subclassResponsibility |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
207 |
|
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
208 |
"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
|
209 |
! |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
210 |
|
4788 | 211 |
release |
212 |
self stopCompletionProcess. |
|
213 |
self closeCompletionView. |
|
214 |
super release |
|
215 |
! |
|
216 |
||
217 |
startCompletionProcess |
|
218 |
"start the code completion process in the background" |
|
219 |
||
220 |
|initialList cursorX cursorY| |
|
221 |
||
222 |
"/ terminate any previous process |
|
223 |
self stopCompletionProcess. |
|
224 |
||
225 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
226 |
"/ 'cl' printCR. |
4788 | 227 |
self closeCompletionView. |
228 |
^ self |
|
229 |
]. |
|
230 |
((cursorX := editView xOfCursor) isNil |
|
231 |
or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[ |
|
232 |
"/ 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
|
233 |
"/ 'cl2' printCR. |
4788 | 234 |
self closeCompletionView. |
235 |
^ self |
|
236 |
]. |
|
237 |
||
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
238 |
completionView isNil ifTrue:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
239 |
initialList := #( 'Busy...' ). |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
240 |
"/ 'op1' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
241 |
] ifFalse:[ |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
242 |
initialList := completionView list. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
243 |
"/ 'op2' printCR. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
244 |
]. |
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
245 |
self openCompletionView:initialList. |
4788 | 246 |
|
247 |
completionProcess := |
|
248 |
[ |
|
5697 | 249 |
"/ protect end-user applications from errors |
250 |
Error handle:[:ex | |
|
251 |
Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ ex reject ] |
|
5960 | 252 |
] do:[ |
5995 | 253 |
(editView topView isDebugView) ifTrue:[ |
5960 | 254 |
ControlInterrupt ignoreIn:[ |
255 |
self computeCompletions. |
|
256 |
]. |
|
257 |
] ifFalse:[ |
|
258 |
self computeCompletions. |
|
259 |
]. |
|
5697 | 260 |
]. |
4788 | 261 |
] forkAt:(Processor activePriority - 1). |
262 |
||
263 |
"Modified: / 26-09-2013 / 17:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
264 |
! |
|
265 |
||
266 |
stopCompletionProcess |
|
267 |
"kill any background completion process" |
|
268 |
||
269 |
|p| |
|
270 |
||
271 |
(p := completionProcess) notNil ifTrue:[ |
|
272 |
completionProcess := nil. |
|
273 |
p terminate. |
|
274 |
]. |
|
275 |
! |
|
276 |
||
277 |
updateCompletionList |
|
278 |
"called for keypress events" |
|
279 |
||
280 |
self startCompletionProcess. |
|
281 |
! ! |
|
282 |
||
283 |
!EditTextViewCompletionSupport methodsFor:'private-API'! |
|
284 |
||
285 |
closeCompletionView |
|
286 |
|v| |
|
287 |
||
288 |
(v := completionView) notNil ifTrue:[ |
|
289 |
completionView := nil. |
|
290 |
"/ let it close itself - avoids synchronization problems |
|
291 |
v sensor |
|
292 |
pushUserEvent:#value |
|
293 |
for:[ v topView destroy ] |
|
294 |
]. |
|
295 |
! |
|
296 |
||
297 |
openCompletionView |
|
298 |
"Opens the completion view with an initial list. Called as soon as |
|
299 |
completion is initiated but completion options are not yet computed." |
|
300 |
||
301 |
self openCompletionView: (Array with: 'Busy...') |
|
302 |
||
303 |
"Created: / 26-09-2013 / 17:06:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
304 |
! |
|
305 |
||
306 |
openCompletionView: list |
|
307 |
"Makes sure the completion view is opened and with given `list`." |
|
308 |
||
5939 | 309 |
| textCursorPosInTextView textCursorPosOnScreen movePos topView |
310 |
screenBounds screenBoundsCorner |
|
311 |
helpViewsExtent helpViewsWidth helpViewsHeight| |
|
4817
597e3af71218
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4808
diff
changeset
|
312 |
|
5939 | 313 |
"/ move the window away from the text cursor (to not cover what user types in) |
314 |
"/ get the screen-relative position of the text cursor |
|
315 |
textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
|
316 |
||
317 |
"/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
|
318 |
textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
|
319 |
||
320 |
textCursorPosOnScreen := editView device |
|
321 |
translatePoint:textCursorPosInTextView |
|
322 |
fromView:editView toView:nil. |
|
323 |
||
4788 | 324 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
5939 | 325 |
"/ this will be somewhat to the down-right of the textCursor |
326 |
movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
|
4788 | 327 |
|
328 |
completionView isNil ifTrue:[ |
|
329 |
completionView := CodeCompletionHelpMenuView new. |
|
330 |
completionView name:'completion'. |
|
331 |
completionView level:0. |
|
332 |
completionView list:list. |
|
333 |
completionView enable:false. |
|
334 |
completionView extent:completionView preferredExtentForContents. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
335 |
"/ completionView font: editView font. |
4788 | 336 |
topView := CodeCompletionHelpView with:completionView. |
4968
254b5e81199a
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4824
diff
changeset
|
337 |
topView editView:editView. |
4788 | 338 |
] ifFalse:[ |
339 |
completionView list:list. |
|
340 |
topView := completionView topView. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
341 |
]. |
5939 | 342 |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
343 |
topView ~~ completionView ifTrue:[ |
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
344 |
topView resizeToFit. |
5939 | 345 |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
346 |
"/ make sure, the window is visible |
5939 | 347 |
screenBounds := topView device monitorBoundsAt:topView origin. |
348 |
screenBoundsCorner := screenBounds corner. |
|
349 |
||
350 |
helpViewsExtent := topView extent. |
|
351 |
helpViewsWidth := helpViewsExtent x. |
|
352 |
helpViewsHeight := helpViewsExtent y. |
|
353 |
||
354 |
"/ if it does not lie completely inside the screen, move it |
|
355 |
(movePos x + helpViewsWidth) > screenBoundsCorner x ifTrue:[ |
|
356 |
movePos := (textCursorPosOnScreen x - 60 - helpViewsWidth) @ movePos y. |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
357 |
]. |
5939 | 358 |
(movePos y + helpViewsHeight) > screenBoundsCorner y ifTrue:[ |
359 |
movePos := movePos x @ (textCursorPosOnScreen y - helpViewsHeight). |
|
5032
395358c11314
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4968
diff
changeset
|
360 |
]. |
5939 | 361 |
movePos y < 0 ifTrue:[ |
362 |
movePos := movePos x @ 0 |
|
363 |
]. |
|
4824
e3806247e940
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
4819
diff
changeset
|
364 |
topView origin:movePos. |
4788 | 365 |
]. |
366 |
||
367 |
"Created: / 26-09-2013 / 17:07:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
368 |
! ! |
|
369 |
||
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
370 |
|
4788 | 371 |
!EditTextViewCompletionSupport class methodsFor:'documentation'! |
372 |
||
373 |
version |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
374 |
^ '$Header$' |
4788 | 375 |
! |
376 |
||
377 |
version_CVS |
|
5410
78eefa911c26
class: EditTextViewCompletionSupport
Claus Gittinger <cg@exept.de>
parents:
5064
diff
changeset
|
378 |
^ '$Header$' |
4788 | 379 |
! ! |
380 |